Tagged: sprintf c programming

sscanf and sprintf functions 19

sscanf and sprintf functions

sscanf() function is used to extract strings from the given string. Consider, char *str = “Learn C Online”; If we want to extract “Learn”, “C” and “Online” in a different variable then it can be done using sscanf function. Syntax: sscanf(characterArray, “Conversion specifier”, address of variables); This will extract the data from the character array according to the conversion specifier and store into the respective variables. sscanf() will read subsequent characters until a whitespace is found (whitespace characters are blank, newline and tab). Let us understand this using an example. char *str = “Learn C Online”; char *first, *second, *third;...