Answers for "my fgets c"

C
3

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;
}
Posted by: Guest on February-04-2022
22

fgets c

<open file>
while(fgets(<char array>, <size of array>, <file pointer>) != null)
Posted by: Guest on December-06-2019

Code answers related to "C"

Browse Popular Code Answers by Language