Rev 8687 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8687 | Rev 8730 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include |
1 | #include |
2 | #include |
2 | #include |
- | 3 | #include |
|
- | 4 | ||
- | 5 | #define READ_MAX 255 |
|
- | 6 | ||
- | 7 | static char test_str1[] = "123454567890abcdefghijklmnopqrstufvwxyz"; |
|
- | 8 | static char test_str2[READ_MAX]; |
|
Line 3... | Line 9... | ||
3 | 9 | ||
4 | int main(int argc, char **argv) |
10 | int main(int argc, char **argv) |
5 | { |
- | |
6 | 11 | { |
|
7 | int i; |
- | |
8 | char c; |
12 | int i=0; |
9 | FILE *f; |
- | |
10 | FILE *fin; |
- | |
Line 11... | Line 13... | ||
11 | FILE *fout; |
13 | FILE *f; |
- | 14 | ||
12 | 15 | //write to file |
|
Line 13... | Line 16... | ||
13 | //write to file |
16 | debug_printf("Write file...\n"); |
14 | f=fopen("testfile.txt","w"); |
- | |
15 | 17 | f=fopen("testfile.txt","w"); |
|
- | 18 | ||
16 | for(i=0;i<50;i++) |
19 | while(test_str1[i]!='a'){ |
17 | { |
20 | fputc(test_str1[i],f); |
Line 18... | Line 21... | ||
18 | fputc('1',f); |
21 | i++; |
- | 22 | } |
|
19 | } |
23 | fclose(f); |
20 | fclose(f); |
- | |
21 | 24 | ||
22 | //append to file |
- | |
23 | f=fopen("testfile.txt","a"); |
25 | //append to file |
24 | - | ||
- | 26 | debug_printf("Apend file...\n"); |
|
25 | for(i=0;i<50;i++) |
27 | f=fopen("testfile.txt","a"); |
Line 26... | Line 28... | ||
26 | { |
28 | fputs(test_str1+i,f); |
27 | fputc('2',f); |
- | |
28 | } |
29 | char null_term = '\0'; |
29 | fclose(f); |
30 | fwrite(&null_term, sizeof(char), 1, f); |
30 | 31 | fclose(f); |
|
31 | //copy from testfile.txt to copyfile.txt |
32 | |
- | 33 | //copy from testfile.txt to copyfile.txt |
|
- | 34 | debug_printf("Read file...\n"); |
|
32 | 35 | f=fopen("testfile.txt","r"); |
|
- | 36 | i=0; |
|
- | 37 | while((test_str2[i]=fgetc(f))!=EOF && i |
|
33 | fin=fopen("testfile.txt","r"); |
38 | fputc(test_str2[i], stdout); |
34 | fout=fopen("copyfile.txt","w"); |
39 | i++; |
35 | /* |
40 | } |
- | 41 | printf("\n%s\n", test_str1); |
|
36 | while((c=fgetc(fin))!=EOF) |
42 | if(!strcmp(test_str2, test_str1)){ |
37 | { |
- | |
38 | fputc(c,fout); |
43 | puts("TEST: OK!"); |
39 | }*/ |
44 | }else{ |