(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 a variable length. for example, scanf ("% d % F", & I, & F) assigns a value to the variables I and F.
Printf willVariableOutputStdout
The prototype of the printf function is: int printf (_ Const char * _ restrict _ format,...), For example: printf ("% d", I) indicates to pass the value of variable I to the standard output.
(2) fscanf and fprintf
Fscanf slaveFileAccept input, output data in the specified formatVariable.
The fscanf function is prototype: int fscanf (File * _ restrict _ stream,_ Const char * _ restrict _ format,...) _ WUR, for example, fscanf (FP, "% d % F", & I, & F) indicates the current data represented by the file pointer, usually one line is output to the variables I and F.
Fprintf willVariableOutputFile
The fprintf function is prototype: int fprintf (File * _ restrict _ stream,_ Const char * _ restrict _ format,...), Such as fprintf (FP, "% d % F", I, F );
(3) sscanf and sprintf
Sscanf slaveStringAccept input, output data in the specified formatVariableTo convert strings to other variables.
The sscanf function is prototype: int sscanf (_ const char * _ restrict _ s, _ const char * _ restrict _ format ,...) _ Throw. For example, sscanf (P, "% d", & I) converts the string represented by P to an integer variable and assigns it to I, if the pointer P points to the string "12345", then I = 12345.
Sprintf outputs variables in the specified formatStringTo convert other types of variables into strings.
Sprintf function prototype: int sprintf (char * _ restrict _ s, _ const char * _ restrict _ format ,...) _ Throw, for example, sprintf (P, "% d", I). If I = 12345, the pointer P points to the memory and stores the string "12345 ".
These functions also support regular expressions, which are very powerful and often used.
Relevant information is worth reading:
Sprintf, how much do you know? Http://blog.csdn.net/sjf331/archive/2005/04/07/339254.aspx
Regular Expressions in sscanf, scanf, and fscanf
Http://ybmmwjl.blog.163.com/blog/static/656387812010102691254484/
Scanf and sscanf
Http://wenku.baidu.com/view/3e3250160b4e767f5acfce85.html