Các thư viện c++

     
#include #include int main(int argc, char *argv<>) tệp tin *in, *out; char ch; if((in=fopen("inFile.txt", "rb")) == NULL) printf("Cannot xuất hiện input file. "); exit(1); if((out=fopen("outFile.txt", "wb")) == NULL) printf("Cannot mở cửa output file. "); exit(1); while(!feof(in)) ch = getc(in); if(ferror(in)) printf("Read Error"); clearerr(in); break; else if(!feof(in)) putc(ch, out); if(ferror(out)) printf("Write Error"); clearerr(out); break; fclose(in); fclose(out); return 0;

Bạn đang xem: Các thư viện c++

#include #include int main(void) tệp tin *fp; if((fp=fopen("test", "rb"))==NULL) printf("Cannot open file. "); exit(1); if(fclose(fp)) printf("File close error. "); return 0;
#include #include int main(void) tệp tin *fp; if((fp=fopen("test", "rb"))==NULL) printf("Cannot open file. "); exit(1); while(!feof(fp)) char ch = getc(fp); printf("%c",ch); fclose(fp);
#include #include int main(void) file *fp; if((fp=fopen("test", "rb"))==NULL) printf("Cannot open file. "); exit(1); putc("C", fp); if(ferror(fp)) printf("File Error "); exit(1); fclose(fp); return 0;
#include #include int main(void){ file *fp; if((fp=fopen("test", "rb"))==NULL) printf("Cannot xuất hiện file. "); exit(1); char ch = "C"; int i; for(i=0; i
#include #include int main(int argc, char *argv<>) file *fp; char ch; if((fp=fopen("test","r"))==NULL) printf("Cannot xuất hiện file. "); exit(1); while((ch=fgetc(fp)) != EOF) printf("%c", ch); fclose(fp); return 0;
#include #include int main(int argc, char *argv<>) file *fp; fpos_t file_loc; if((fp=fopen("test","r"))==NULL) printf("Cannot mở cửa file. "); exit(1); fgetpos(fp, &file_loc); fclose(fp);
#include #include int main(int argc, char *argv<>) file *fp; char str<128>; if((fp=fopen("test", "r"))==NULL) printf("Cannot xuất hiện file. "); exit(1); while(!feof(fp)) if(fgets(str, 126, fp)) printf("%s", str); fclose(fp); return 0;
//Mode Meaning//"r": open text tệp tin for reading //"w": Create a text file for writing //"a": Append to text file //"rb": mở cửa binary tệp tin for reading //"wb": Create binary tệp tin for writing //"ab": Append to lớn a binary file //"r+": mở cửa text file for read/write //"w+": Create text tệp tin for read/write //"a+": open text tệp tin for read/write //"rb+" or "r+b": xuất hiện binary tệp tin for read/write //"wb+" or "w+b": Create binary file for read/write //"ab+" or "a+b": open binary tệp tin for read/write #include #include int main(int argc, char *argv<>) tệp tin *fp; if ((fp = fopen("test", "w"))==NULL) printf("Cannot mở cửa file. "); exit(1); fclose(fp);
#include #include int main(void) tệp tin *fp; if((fp=fopen("test", "wb"))==NULL) printf("Cannot xuất hiện file. "); exit(1); //The format control string are identical to lớn those in printf(); fprintf(fp, "this is a test %d %f", 10, 20.01); fclose(fp); return 0;
#include #include int main(void) file *fp; if((fp=fopen("test", "wb"))==NULL) printf("Cannot mở cửa file. "); exit(1); char *str = "www.java2s.com"; while(*str) if(!ferror(fp)) fputc(*str++, fp); fclose(fp);
#include #include int main(void) file *fp; if((fp=fopen("test", "wb"))==NULL) printf("Cannot open file. "); exit(1); fputs("this is a test", fp); fclose(fp);
#include #include int main(void) { tệp tin *fp; float bal<5> = 1.1F, 2.2F, 3.3F, 4.4F, 5.5F ; int i; if((fp=fopen("test", "wb"))==NULL) printf("Cannot open file. "); exit(1); if(fwrite(bal, sizeof(float), 5, fp) != 5) printf("File read error."); fclose(fp); if((fp=fopen("test", "rb"))==NULL) printf("Cannot xuất hiện file. "); exit(1); if(fread(bal, sizeof(float), 5, fp) != 5) if(feof(fp)) printf("Premature end of file."); else printf("File read error."); fclose(fp); for(i=0; i
/Mode Meaning//"r": mở cửa text file for reading //"w": Create a text tệp tin for writing //"a": Append to lớn text tệp tin //"rb": open binary file for reading //"wb": Create binary tệp tin for writing //"ab": Append khổng lồ a binary file //"r+": open text file for read/write //"w+": Create text tệp tin for read/write //"a+": open text tệp tin for read/write //"rb+" or "r+b": open binary file for read/write //"wb+" or "w+b": Create binary file for read/write //"ab+" or "a+b": mở cửa binary tệp tin for read/write #include #include int main(void) tệp tin *fp; printf("This will display on the screen. "); if((fp=freopen("OUT", "w" ,stdout))==NULL) printf("Cannot xuất hiện file. "); exit(1); printf("This will be written to the file OUT."); fclose(fp); return 0;
#include #include int main(void) tệp tin *fp; float bal<5> = 1.1F, 2.2F, 3.3F, 4.4F, 5.5F ; int i; if((fp=fopen("test", "wb"))==NULL) printf("Cannot xuất hiện file. "); exit(1); if(fwrite(bal, sizeof(float), 5, fp) != 5) printf("File read error."); fclose(fp); char str<80>; float f; fscanf(fp, "%s%f", str, &f); fclose(fp);
//Name Meaning//SEEK_SET: Seek from start of file //SEEK_CUR: Seek from current location //SEEK_END: Seek from end of tệp tin #include #include struct fullname char firstName<40>; char lastName<10>; info; int main(void) tệp tin *fp; if((fp=fopen("test", "rb")) == NULL) printf("Cannot open file. "); exit(1); int client_num = 10; /* find the proper structure */ fseek(fp, client_num*sizeof(struct fullname), SEEK_SET); /* read the data into memory */ fread(&info, sizeof(struct fullname), 1, fp); fclose(fp);
#include #include int main(int argc, char *argv<>) file *fp; fpos_t file_loc; if((fp=fopen("test","r"))==NULL) printf("Cannot mở cửa file. "); exit(1); fgetpos(fp, &file_loc); fsetpos(fp, &file_loc); fclose(fp);
#include #include int main(void) file *fp; if((fp=fopen("test", "rb")) == NULL) printf("Cannot open file. "); exit(1); int i; if((i=ftell(fp)) == -1L) printf("A tệp tin error has occurred. "); fclose(fp);
#include #include int main(void) file *fp; float f=12.23; if((fp=fopen("test", "wb"))==NULL) printf("Cannot xuất hiện file. "); exit(1); fwrite(&f, sizeof(float), 1, fp); fclose(fp); return 0;

Xem thêm: Hướng Dẫn Cách Chơi Modern Combat 5 Trên Pc Cho Tân, Modern Combat 5

#include #include int main(int argc, char *argv<>) file *fp; char ch; if((fp=fopen("test", "r"))==NULL) printf("Cannot open file. "); exit(1); while((ch=getc(fp))!=EOF) printf("%c", ch); fclose(fp); return 0;
#include int main(void) char s<256>, *p; p = s; printf("input char:"); while((*p++ = getchar())!= " "); *p = ""; /* địa chỉ null terminator */ printf(s); return 0; /*input char:123123*/
#include #include int main(void) char fname<128>; printf("Enter filename: "); gets(fname); printf("%s ", fname); return 0; /*Enter filename: 321321*/
#include int main(void) tệp tin *fp; if((fp=fopen("test", "w"))==NULL) printf("Cannot mở cửa file. "); exit(1); char *str = "www.java2s.com"; for(; *str; str++) putc(*str, fp);
#include #include int main(void) char str<80>; strcpy(str, "this is an example"); puts(str); return 0; remove: delete file by *fname
#include int main(int argc, char *argv<>) if(rename("oldName", "newName") != 0) printf("Rename Error"); return 0;
#include #include int main(int argc, char *argv<>) file *fp; if((fp=fopen("test", "r"))==NULL) printf("Cannot mở cửa file. "); exit(1); while(!feof(fp)) putchar(getc(fp)); rewind(fp); while(!feof(fp)) putchar(getc(fp)); fclose(fp);
#include int main(void) char str<80>, str2<80>; int i; scanf("%79s", str); //scanf up lớn 79 chars into str return 0;
#include int main () char buffer; file *fp1, *fp2; fp1=fopen ("test.txt","w"); fp2=fopen ("test2.txt","a"); setbuf ( fp1 , buffer ); fputs ("This is sent khổng lồ a buffered stream",fp1); fflush (fp1); setbuf ( fp2 , NULL ); fputs ("This is sent to lớn an unbuffered stream",fp2); //Set buf lớn null to lớn turn off buffering. //The buffer must be BUFSIZ characters long. //BUFSIZ is defined in . Fclose (fp1); fclose (fp2); return 0;
#include int main () tệp tin *fp; fp=fopen ("myfile.txt","w"); setvbuf ( fp , NULL , _IOFBF , 1024 ); // tệp tin operations here fclose (fp); return 0;
#include int main () char buffer <50>; int n, a=5, b=3; n=snprintf (buffer, 5,"%d plus %d is %d", a, b, a+b); printf ("<%s> is a %d char long string ",buffer,n); return 0;
#include int main(void) char str<80>; int i; sscanf("hello 1 2 3 4 5", "%s%d", str, &i); printf("%s %d", str, i); return 0;
tmpfile: opens a temporary binary tệp tin for read/write operations and returns a pointer to the stream

#include int main(void) file *temp; if((temp=tmpfile())==NULL) printf("Cannot open temporary work file. "); exit(1);
#include int main (){ file * fp; int c; char buffer <256>; fp = fopen ("test.txt","rt"); if (fp==NULL) perror ("Error opening file"); else { while (!feof (fp)) { c=getc (fp); if (c == "#") ungetc ("
*
*
trả lời cùng cùng với trích dẫn
Quick NavigationThủ thuật, Tutorials cùng Mã mối cung cấp C/C++/C++0xTopCác quanh vùng của siteCác diễn đànCỘNG ĐỒNG C VIỆTĐỊNH HƯỚNG, ĐÀO TẠO và VIỆC LÀM NGÀNH CNTTLẬP TRÌNH VISUAL C#LẬP TRÌNH OBJECTIVE-CLẬP TRÌNH JAVALẬP TRÌNH VISUAL C++ | LẬP TRÌNH VISUAL C++.NETLẬP TRÌNH C++ | LẬP TRÌNH C | LẬP TRÌNH C++0XLẬP TRÌNH TRÊN LINUX | LINUX PROGRAMMINGDATABASE và REPORTING | CÁC HỆ QUẢN TRỊ DATABASETHÀNH VIÊN CỘNG ĐỒNG C VIỆTTHẢO LUẬN CHUNGCHUYÊN MỤC GIẢI TRÍ
*
Quyền hạn của bạn
qqlive| j88