C language uses the getchar method to clear the input buffer and the use of the fgets function

The processing speed of the computer CPU is very fast. The speed of our keyboard input is not as fast as the processing speed of the CPU. The CPU has to wait for the keyboard input to be completed, which is a waste of resources. Improve efficiency. getchar: Function declaration: int getchar(void); Character input function, […]

Standard IO_file reading and writing_fgetc, getchar, ungetc, fgets, fputs, fread, fwrite

Directory 1. Single-character file reading and writing 1.1 Single character read file 1.1.1 fgetc function 1.1.2 getc function 1.1.3 getchar function 1.1.4 ungetc function 1.1.5 Comprehensive sample code for reading single-character files 1.2 Single-character write file 1.2.1 fputc function 1.2.2 putc function 1.2.3 putchar function 1.2.4 Comprehensive sample code for single-character write file 2. Multi-character […]

Standard IO process thread functions: fopen, perror, fclose, fprintf, fscanf, fputc, fgetc, buffer, fputs, fgets, fwrite, fread, fseek, ftell,

Standard IO functions: 1. Stream pointer (FILE*): FILE* fp=fopen(“1.txt”,”r”): This fp is a stream pointer. When this file is opened in read-only mode, a buffer will be applied for at the same time. At this time, the stream pointer fp It will contain the information of the current reading position of the file, if it […]

Standard IO interface functions setbuf fprintf sprintf sscanf fscanf fgetc fgets fopen freopen function 5.12

setbuf /*================================================ == * File name: setbuf_demo.c * Created by: memories * Creation date: May 09, 2023 * describe: ===================================================*/ #include <stdio.h> int main(int argc, char *argv[]) {<!– –> /* * stdout: standard output stream * stdin: standard input stream * stderr: standard error output stream * * printf() is a line buffer function, only […]

c/c++: gets(), fgets(), puts(), fputs(), strlen(), string concatenation function

c/c++: gets(), fgets(), puts(), fputs(), strlen(), string concatenation function Finding a job in 2022 is a super combination of education, ability and luck. In the cold winter, big factories do not recruit people. If you learn c++ at this time, As far as I know, students who know C ++ can hold more than 10 […]

C language file operation, introduction of fopen, fclose, fgetc, fgets, fputc, fputs, fwrite, fread, feof, ferror, fprintf, fscanf and other file functions

Article directory Why use files what is a file file opening and closing file pointer file opening and closing Sequential reading and writing of files Compare a set of functions Random reading and writing of files fseek ftell function rewind function text files and binary files Judgment of the end of file reading misused feof […]

Explanation of c language file operation functions; fopen(); fputs(); fgets(); fflush(); fsync(); fileno(); open(); fclose();

Directory 1. What is a file Second, the meaning of the file pointer 3. Common operable functions in files 1) fopen(); Explanation 2) fputs(); Explanation 3) fgets(); Explanation 4) fflush(); Explanation 5) fsync(); Explanation 6) fileno(); Explanation 7) fclose(); Explanation 4. Example explanation 1) Basic example 2) Advanced example Five, open (); explanation 1. What […]