All pastes #53762 Raw Edit

fgets

public c v1 · immutable
#53762 ·published 2006-05-05 20:29 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){	char foo[5];	char c;	if(fgets(foo, 5, stdin) != NULL)	{		if(strchr(foo, '\n') == NULL)		{			do c = fgetc(stdin);			while(c != EOF && c != '\n');		}		else foo[strlen(foo) - 1] = '\0';	}	puts(foo);	return 0;}