1.
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include <myku.h>
5 int main(int argc, const char *argv[])
6 {
7 FILE *p=fopen("ceshi.txt","r");
8 if(NULL==p)
9 {
10 ERR_MSG("fopen");
11 return -1;
12 }
13
14 char s[30];
15 int count=0;
16 while(fgets(s,sizeof(s),p)!=NULL)
17 {
18 count++;
19 }
20 printf("count=%d\n",count);
21 fclose(p);
22 return 0;
23 }
2.
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include <myku.h>
5 int main(int argc, const char *argv[])
6 {
7 FILE *p1=fopen("ceshi.txt","r");
8 if(NULL==p1)
9 {
10 ERR_MSG("fopen");
11 return -1;
12 }
13 FILE *p2=fopen("t.txt","w");
14 if(NULL==p2)
15 {
16 ERR_MSG("fopen");
17 return -1;
18 }
19
20 char c;
21 while(fread(&c,sizeof(c),1,p1)!=0)
22 {
23 fwrite(&c,sizeof(c),1,p2);
24 }
25
26 fclose(p1);
27 fclose(p2);
28 return 0;
29 }
3.xmind