Concept

How do sscanf() and sprintf() work with strings?

ComputerScienceOne / Tokenizing

"The sscanf() function differs in its first argument: the string that contains the value you want to parse. Otherwise, the second two arguments are as in scanf(): the format (as a string) and the variable(s) that the results should be stored in (passed by reference). Likewise, there is a companion sprintf() which is similar to the printf() function, but instead of printing to the standard output, it “prints” to the string. That is, the result is placed in a string.\n\nint x = 10;\n\ndouble y = 3.14;\n\nchar *s = (char *) malloc(sizeof(char) * 50);\n\nsprintf(s, \"The value of x is %d, y = %f.\", x, y);\n\n// s now contains \"The value of x is 10, y = 3.140000.\""

Related Ideas

How do sscanf() and sprintf() work with strings? | ComputerScienceOne | Bifalgorithm | Bifalgorithm