Method sscanf() ambiguous behavior

Posted by Carmen Cojocaru on Stack Overflow See other posts from Stack Overflow or by Carmen Cojocaru
Published on 2013-11-09T20:07:21Z Indexed on 2013/11/09 21:54 UTC
Read the original article Hit count: 151

Filed under:

I am trying to understand how sscanf() works. I ran some examples from this page: http://docs.roxen.com/pike/7.0/tutorial/strings/sscanf.xml and they don't work on my platform. I can't understand why. For instance: "sscanf("4711bar", "%d%s", a, b);" makes the program exit with an error...

Here is one of the examples that work: "sscanf("foo", "f%s", a);". Does anybody know why? Do they work on your platforms? Thank you.

This is my code:

 int main(void){

   char *b = (char*)malloc(sizeof(char)*100);       
   int a = 0;

   sscanf("4711bar", "%d%s", a, b);
   printf("%d", a);
   printf("%s", b);
 }

© Stack Overflow or respective owner

Related posts about c