(1) fgets:
Header file
Include
Define functions
Char * fgets (char * s, int size, FILE * stream );
Function Description
Fgets () is used to read characters from the file referred to by the parameter stream to the memory space referred to by the parameter s until a line break
, processing such data, just one line. I tidied up the code and removed the irrelevant parts, the core part is as follows:float price;int quantity;Char category[21], name[21];Char vendor[21], sku[21];Char buf[201];fp = fopen (filename, "R");Fgets (buf, (+), FP);SSCANF (BUF,"%20[^#]#%20[^#]#%f#%i#%20[^#]#%20[^/n]",Name, SKU, price, quantity, category, vendor);Here are some simple explanations:%20[^#]# reads
Sscanf
Name:
Sscanf ()-read data that matches the specified format from a string.
Function prototype:
Int sscanf (string STR, string FMT, mixed var1, mixed var2 ...);
Int scanf (const char * Format [, argument]...);
Note:
Similar to scanf, sscanf is used for input, but the latter uses the screen (stdin) as the input so
the time-conversion subroutine Asctime, localtime, and gmtime, the types used for CTime, Difftime, Gmtime, localtime, and Stime, and provides prototypes of these functions.VALUE. H defines some important constants, including those that depend on machine hardware and some constants that are described for compatibility with Unix System V, including the range of floating-point and double-precision values.C how to read data from a comma-separated file in a languageTo have commas, just add commas,2,
---restore content starts---It's been hit today, isn't it? By Zheng Light of the ACM teacher to my college guidance arranged a small game,, we actually have or lost to a freshman novice,, Hey, love,,, so still want to pay attention to the basic programming ability training, now I began to learn the format of the input, very complex but very effective ...SSCANF ()-Reads data in a string that matches the specified format.Int
usage and examples of sscanf ()Here are some sscanf () some of the use of instructions, are from the Forum, blog organized out. For everyone to use.
Through the study and use of personal thinking, in the string format is not very complex, but it is not easy to use this function more appropriate, this scale depends on their own grasp, the string is not very complex, but their own writing a processing functio
Sscanf usageName:Sscanf ()-read data that matches the specified format from a string.Function prototype:Int sscanf (string STR, string FMT, mixed var1, mixed var2 ...);Int scanf (const char * Format [, argument]...);Note:Similar to scanf, sscanf is used for input, but the latter uses the keyboard (stdin) as the input source, and the former uses a fixed string as
/* Non-blog summary */
Sscanf
Name:Sscanf ()-read data that matches the specified format from a string.Function prototype:Int sscanf (string str, string fmt, mixed var1, mixed var2 ...);Int scanf (const char * format [, argument]...);Note:Similar to scanf, sscanf is used for input, but the latter uses the screen (stdin) as the input source, and the former uses a
Sscanf ()-read data that matches the specified format from a string.
Function prototype:
Int sscanf (const char *, const char *,...);Int scanf (const char *,...);
Header file:
# Include
Note:
Similar to scanf, sscanf is used for input, but the latter uses the keyboard (stdin) as the input source, and the former uses a fixed string as the input source.
The first
reproduced from: http://baike.baidu.com/view/1364018.htm
Name:SSCANF ()-Reads data from a string that matches the specified format. function prototypes: int sscanf (const char *, const char *, ...); int sscanf (const char *buffer,const char *format,[argument] ...); Buffer stored data Format format Control string argument Optional set string sscanf will read
#include Defines the function int sscanf (const char *str,const char * format,........);Function descriptionSSCANF () Converts and formats the data in the string based on the parameter format string. Format conversion form please refer to scanf ().The converted result is stored in the corresponding number of parameters.The return value succeeds returns the number of parameters, and the failure returns 1, and the reason for the error is stored in errno
Name:
sscanf ()-Reads data from a string that matches the specified format.
Copy Code code as follows:
Function Prototypes:
Int sscanf (String str, String fmt, mixed var1, mixed var2 ...);int scanf (const char *format [, argument] ...);
Description:SSCANF is similar to scanf and is used for input, except that the latter takes the screen (stdin) as the input source, with a fixed st
Sscanf ()
Sscanf ()
2011-11-23 09:07:56........ I have been crawling recently. The STL of C ++ makes me tangle with the lack of support for regular expressions. I should use regular expressions unless I install the boost library, but I am very lazy, considering the running efficiency, boost has not been installed since it was downloaded. All functions used to extract information from crawlers are self
SSCANF ()-Reads data in a string that matches the specified format.Function Prototypes:int sscanf (String str, String fmt, mixed var1, mixed var2 ...);int scanf (const char *format [, argument] ...);DescriptionSSCANF is similar to scanf, which is used for input, except that the latter takes a screen (stdin) as the input source, the former with a fixed string as the input source.Where format can be one or mo
Example:1. Common usage. char buf[512] =;sscanf ("123456", "%s", buf);printf ("%s\n", buf);The result is: 1234562. Take a string of the specified length.As in the following example, take a string with a maximum length of 4 bytes. sscanf ("123456", "%4s", buf);printf ("%s\n", buf);The result is: 12343. The string to take to the specified character.As in the following example, the string is encountered until
In my learning process, reading data from a file is a very troublesome thing, fortunately there is a sscanf () function.The use of C-language function sscanf ()SSCANF ()-Reads data in a string that matches the specified format.Function Prototypes: int string string fmt, mixed var1, mixed var2 ...); intconstchar *format [, argument] ...); Description
The following is a detailed analysis of the use of the SSCANF function in C language, the need for friends under the reference
Name: sscanf ()-Reads data from a string that matches the specified format.
Copy Code code as follows:
function Prototype:
Int sscanf (String str, String fmt, mixed var1, mixed var2 ...);int scanf (const char *format [, argument]
In my learning process, reading data from a file is very troublesome. Fortunately, there are sscanf () functions.
C language function sscanf () Usage
Sscanf ()-read data that matches the specified format from a string.Function prototype:Int sscanf (string STR, string FMT, mixed var1, mixed var2 ...);Int scanf (c
# Include
Define the function int sscanf (const char * STR, const char * format ,........);
Function DescriptionSscanf () converts and formats the STR string based on the format string. For more information about format conversion, see scanf (). The converted result is stored in the corresponding parameter.
If the return value is successful, the number of parameters is returned. If the return value fails,-1 is returned. The error cause is store
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.