Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

myFgets in c

#include <stdlib.h>
#include <string.h>

char* myFgets();

/*
	this function is better version of fgets
    input: NONE
    output: pointer to the first char in the str
*/

char* myFgets()
{
	char tempStr[BIG_NUM] = { 0 };
	char* str = NULL;
	fgets(tempStr, BIG_NUM, stdin);
	str = (char*)malloc(sizeof(char) * strlen(tempStr));
	tempStr[strcspn(tempStr, "
")] = 0;
	strcpy(str, tempStr);
	return str;
}
 
PREVIOUS NEXT
Tagged: #myFgets
ADD COMMENT
Topic
Name
8+1 =