[ create a new paste ] login | about

Link: http://codepad.org/TFiDlRGB    [ raw code | output | fork ]

C, pasted on Apr 30:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdio.h>
int main()
{
   int i;
   char text[BUFSIZ];
   char* inputs[] = { "stuff\n", "", "\n", "more stuff\n" };
   for (i = 0; i < sizeof inputs / sizeof *inputs; i++) {
      int result = sscanf(inputs[i], "%[^\n]", text);
      if (result == 1) {
         printf("good: text=\"%s\"\n", text);
      }
      else {
         printf("bad: input=\"%s\"\n", inputs[i]);
      }
   }
   return 0;
}


Output:
1
2
3
4
5
good: text="stuff"
bad: input=""
bad: input="
"
good: text="more stuff"


Create a new paste based on this one


Comments: