Hi i am trying to use sscanf to test if a string is integer or not but it is always giving zero as return value(j) and when it is giving 1(sometimes without any changes) its not populating correct value in receivable variable(i) !Here is my code:
#include <stdio.h>
int main ()
{
char sentence []="123456";
int i=0;
j = sscanf(sentence,"%[0-9]",&i);
return 0;
}
Please let me know where i am going wrong !I know there are other ways to test a string for integer but i want to know where i am going wrong ! Help will be highly appreciated ! Thanks in advance