User Tools

Site Tools


c:stdio.h:scanf

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:stdio.h:scanf [2014/05/17 23:11]
177.33.172.137 [C Sourcecode Example]
c:stdio.h:scanf [2015/03/09 23:24] (current)
Daniel Gohlke max 20 chars Because must has '\0' end. scanf("%s", input); input is an array name and also a pointer, so not to add '&'. thanks to Cmkuoster for the hint
Line 24: Line 24:
   char input[20];   char input[20];
  
-  printf ("Enter some Text (max 21 chars) "); +  printf ("Enter some Text (max 20 chars) "); 
-  scanf ("%s",&input);  +  scanf ("%s",input);  
   printf ("Scanf input was %s.\n",input);   printf ("Scanf input was %s.\n",input);
      
Line 34: Line 34:
 ==== output ==== ==== output ====
     output: ./scanf      output: ./scanf 
-    Enter some Text (max 21 chars) Hello this is a test for scanf    +    Enter some Text (max 20 chars) Hello this is a test for scanf    
     Scanf input was Hello.     Scanf input was Hello.
  
advertising
c/stdio.h/scanf.1400361063.txt · Last modified: 2014/05/17 23:11 by 177.33.172.137

Impressum Datenschutz