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, "\n")] = 0;
strcpy(str, tempStr);
return str;
}
Proud Platypus