摘要:
1 //fread函数的作用是从指定文件中读入指定长度的数据块 2 //fread(buffer,size,count,文件指针) 3 #include 4 #include 5 int main(){ 6 struct Book_Type{ 7 char name[10]; 8 int price; 9 char aut... 阅读全文
摘要:
1 //fwrite函数的作用是将指定长的数据写入文件中 2 //fwrite(fp,size,count,文件指针) 3 #include<stdio.h> 4 #include<stdlib.h> 5 int main(){ 6 struct Book_Type{ 7 char name[10] 阅读全文
摘要:
1 //fscanf函数从指定的文件中按指定格式读入数据,与scanf函数作用类似,scanf从键盘输入,fscanf从文件输入 2 #include 3 #include 4 int main(){ 5 FILE *fp; 6 int i,j; 7 double m,n; 8 char s1[100],s2[100],s3[100],s4[100... 阅读全文
摘要:
1 //fprintf函数将数据按指定格式写入指定文件中,与printf函数相似 2 //形式为 fprintf(文件指针,格式字符串,输出列表) 3 #include 4 #include 5 int main(){ 6 FILE *fp; 7 int i=10,j=12; 8 double m=1.5,n=2.345; 9 char s[]=... 阅读全文
摘要:
1 //fgets函数的作用是从指定文件中读取n-1个字符,然后在最后添加一个'\0'字符作为字符串结束的标志 2 //如果在读完n-1个字符之前遇到一个换行符或者EOF,则读入结束 3 #include 4 #include 5 int main(){ 6 FILE *fp; 7 char str[100]; 8 int n; 9 if( (f... 阅读全文
摘要:
1 //fputs函数是把字符串写入指定文件中 2 #include 3 #include 4 int main(){ 5 FILE *fp; 6 char str[20]; 7 if((fp=fopen("file_data.txt","w"))==NULL ){ 8 printf("打开文件失败\n"); 9 exit... 阅读全文
摘要:
1 //fgetc函数 2 //fgetc函数的作用是从指定的文件读入一个字符 3 #include 4 #include 5 int main(){ 6 FILE *fp; 7 char ch; 8 if( (fp=fopen("file_data.txt","r"))==NULL ){ 9 printf("打开文件失败\n"); 10... 阅读全文
摘要:
1 //fputc函数 2 //将一个字符写进一个文件中 3 #include 4 #include 5 int main(){ 6 FILE *fp; 7 char ch; 8 if( (fp=fopen("file_data.txt","w"))==NULL ){ 9 printf("打开文件失败\n"); 10 ... 阅读全文
摘要:
1 //typedef应用举例 2 #include 3 typedef int INTEGER; 4 typedef struct{ 5 int year; 6 int month; 7 int day; 8 }DATE; 9 10 typedef int COUNT[10]; 11 12 int main(){ 13 INTEGER i;... 阅读全文