Shows the usage of sscanf
Code: -
#include <stdio.h>
int stdinGet (int* p_dest)
{
int ret = 0;
if (p_dest != NULL)
{
char buffer[32];
if (fgets(buffer, sizeof buffer, stdin) != NULL)
{
ret = sscanf (buffer, "%d", p_dest);
}
printf("%s", buffer);
}
return ret;
}
int main(void)
{
int n;
int ret = stdinGet(&n);
if (ret == 1)
{
printf("%d\n", n);
}
return 0;
}
Pradyut
http://pradyut.tk
http://spaces.msn.com/members/oop-edge/
http://groups-beta.google.com/group/oop_programming
India
No comments:
Post a Comment