Everything is a metaphor. What a wonderful world.

0%

1
2
3
4
5
6
7
8
9
-Pro Edition-
License: speedzodiac
Key: Uo9dxksy5DWICB3cs3plwJY+SUAf2Uzj9tdnR1YonltOYi/om6GiHg56/rYGAFED
-Enterprise Edition-
License: speedzodiac
Key: gfr5AXyCSuRBR9fuYkqAGrquTNljcFpj+I3bUfbRDqGyl1z9ymJLQ7+wplKH+5kw
-Team Edition-
License: speedzodiac
Key:sMvFiZpsDkS6SANJ1RV3xhOGKyeK0Z6XVwhJXO5GxPdiGvaIAKP39c5GCR5H6MLH
Read more »

1
2
License: zdfans
Key: fZw2VoYzXakllUuLVdTH13QYWnjD6NZrxgubQkaRyxD5+HNMqdr+WZKkaa6IoE5N
Read more »

C语言中数组大小不能为变量,即使这个变量已经被赋过值了,应该使用malloc方法进行数组空间动态分配。
如下:

1
int *data=(int *)malloc(sizeof(int)*dataCount);
Read more »

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
#include <stdlib.h>

int main() {
FILE *inputFile;
inputFile = fopen("data.bin", "rb");
if (!inputFile) {
fprintf(stderr, "Can't open bin file!");
exit(1);
}

fseek(inputFile, 0, SEEK_END);
long inputFileLength = ftell(inputFile);
printf("input file length: %ld\n", inputFileLength);
fseek(inputFile, 0, SEEK_SET);

fclose(inputFile);
return 0;
}
Read more »

1. 使用strcat进行字符串拼接

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
char *firstName = "Theo";
char *lastName = "Tsao";
char *name = (char *) malloc(strlen(firstName) + strlen(lastName));
strcpy(name, firstName);
strcat(name, lastName);
printf("%s\n", name);
return 0;
}

2. 使用sprintf进行字符串拼接

1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
char *firstName = "Theo";
char *lastName = "Tsao";
char *name = (char *) malloc(strlen(firstName) + strlen(lastName));
sprintf(name, "%s%s", firstName, lastName);
printf("%s\n", name);
return 0;
}
Read more »