The input and output statements of C language include: "getchar(void);" and "putchar(int c);", "scanf("format control string", address list);" and "printf( "Format control string ", output list);", "gets()" and "puts()" and so on.
Tutorial recommendation: "c language tutorial video"
1: Console input Output
(1) Input/output of character data
Character outputputchar(int c);
Character inputgetchar(void);
(2) Formatted input/output
Format outputprintf("Format control string", output list);
Format inputscanf("Format control string", address list);
(3) String input/output
String outputputs(const char *str);
String inputgets(char *str);
scanf cannot accept spaces, Tab, carriage return, etc.; processing of the carriage return character at the end: keep the carriage return character in the cache.
gets can accept spaces, tab characters, carriage returns, etc.; the processing of the carriage return character at the end: accept the carriage return, but replace the carriage return with \0.
2: Reading and writing files
(1) Read and write a character
Character writing functionfputc (c,fp);
Character reading functionfgetc(fp);
(2)Block reading and writing
Binary writing functionfwrite(buffer,size,count,fp);
Binary read functionfread(buffer,size,count,fp);
Format Formatted writing functionfprintf (file pointer, format string, output item list);
Formatted reading functionfscanf (file pointer, format string, address parameter list) ;
(3) Other reading and writing functions
Disk file writing functionputw(10,fp);
Disk file reading functiongetw(fp);
File string writing functionfputs(string, file pointer);
File string reading functionfgets (string array name, n, file pointer);
For more programming-related knowledge, please visit:Programming Learning Website! !
The above is the detailed content of What are the input and output statements in C language?. For more information, please follow other related articles on the PHP Chinese website!