Home > Backend Development > C#.Net Tutorial > What are the input and output statements in C language?

What are the input and output statements in C language?

青灯夜游
Release: 2020-11-03 11:25:53
Original
36601 people have browsed it

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.

What are the input and output statements in C language?

Tutorial recommendation: "c language tutorial video"

1: Console input Output

(1) Input/output of character data

Character outputputchar(int c);

Character input getchar(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 function fwrite(buffer,size,count,fp);

Binary read functionfread(buffer,size,count,fp);

Format Formatted writing function fprintf (file pointer, format string, output item list);

Formatted reading function fscanf (file pointer, format string, address parameter list) ;

(3) Other reading and writing functions

Disk file writing functionputw(10,fp);

Disk file reading function getw(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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template