First, put the classic method above the topic:
In the following cases, a large amount of regular data is stored in the formatted reading method of the file:
Almond # eed9c4
Antique brass # c88a65
Cot cot # fdd5b1
Aquamarine #71d9e2
Asparagus #
Summary of Functions Fgets and fputs, Fread and Fwrite, fscanf, and fprintf usagestring read and Write functions fgets and fputsThe function of reading a string function Fgets function is to read a string into a character array from the specified
Print, fprint, fscanf, and disp functions of MATLAB
Print:
The print function can save the function image as an image:
Minbnd =-4 * PI; maxbnd = 4 * PI; t = minbnd: 0.1 * Pi: maxbnd; plot (T, sin (t), 'G', 'linewidth ', 2); line ([minbnd,
String read/write functions fgets and fputs
1. The fgets function of the string reading function reads a string from a specified file to a character array. The function is called in the form of fgets (character array name, n, file pointer );N is a
This is written for the push box game, some time learning C language, recently turned to Windows design, do not know whether there is the same feeling, the back of the things learned, the front is a little rusty. In fact, my understanding is that
one, the function of the approximate difference:
①fgets: Read a row of data from the file into the buffer (Fgets encountered a carriage return will end, no space and carriage return to do any conversion to the buffer, after the end of the buffer to
scanf, FSCANF is similar, reads input from the stream and assigns a value to the variableint scanf (const char *format, ...)int fscanf (FILE *stream, const char *format,...)%c single character%[] a character set* Input entries are skipped after they
(1) scanf and printf
Scanf slaveStdinInput is accepted, and the data is output to the variable in the specified format.
The original scanf function is: int scanf (_ Const char * _ restrict _ format,...) _ WUR, where... is a variable parameter with
Print :The print function can save a function graphic as a picture:Minbnd = -4*pi;Maxbnd = 4*pi;t = minbnd:0.1*pi:maxbnd;Plot (t, sin (t), ' G ', ' linewidth ', 2);Line ([Minbnd, Maxbnd], [0, 0]); % Draw X axisAxis ([-10, 10,-2, 2])% defines the
first of all, fscanf and fgets These two file functions of the concept of a deep understanding of the string input for the two functions have a typical difference is: fscanf read a space or carriage return will be converted to a blank space or enter/
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.