codescracker


c

C sscanf()



« Previous Function Next Function »


sscanf()

The sscanf() function is same as scanf() function except that the data is read from the array pointed to by buf rather that stdin.

sscanf() Syntax

#include<stdio.h>
int sscanf(const char *buf, const char *format, ...);

The return value is equal to the number of variables that were actually assigned values. And this number does not include fields that were skipped through use of the * format command modifiers. A value of zero means that no fields were assigned, and EOF indicates that an error occurred prior to the first assignment.

sscanf() Example

Following c program prints the message hello 1 on the screen:

#include<stdio.h>
#include<conio.h>
void main()
{
	clrscr();
	char str[80];
	int i;
	sscanf("hello 1 2 3 4 5", "%s%d", str, &i);
	printf("%s %d", str, i);
	getch();
}

« Previous Function Next Function »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test