Back to index

glibc  2.9
Functions
tst-gets.c File Reference
#include <stdio.h>
#include <string.h>

Go to the source code of this file.

Functions

int main (void)

Function Documentation

int main ( void  )

Definition at line 25 of file tst-gets.c.

{
  char buf[100];
  int result = 0;

  if (gets (buf) != buf)
    {
      printf ("gets: read error: %m\n");
      result = 1;
    }
  else if (strchr (buf, '\n') != NULL)
    {
      printf ("newline not stripped: \"%s\"\n", buf);
      result = 1;
    }
  else if (strcmp (buf, "foo") != 0)
    {
      printf ("read mismatch: expected \"%s\", got \"%s\"\n", "foo", buf);
      result = 1;
    }

  if (gets (buf) != buf)
    {
      printf ("gets: read error: %m\n");
      result = 1;
    }
  else if (strchr (buf, '\n') != NULL)
    {
      printf ("newline not stripped: \"%s\"\n", buf);
      result = 1;
    }
  else if (strcmp (buf, "bar") != 0)
    {
      printf ("read mismatch: expected \"%s\", got \"%s\"\n", "bar", buf);
      result = 1;
    }

  return result;
}

Here is the call graph for this function: