mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-16 03:42:35 +03:00
26 lines
347 B
C
26 lines
347 B
C
|
#include <stdio.h>
|
||
|
|
||
|
char * fgets ( char * str, int num, FILE * stream )
|
||
|
{
|
||
|
int rd = 0;
|
||
|
char c;
|
||
|
while (rd < num - 1)
|
||
|
{
|
||
|
c = fgetc(stream);
|
||
|
if (EOF == c) break;
|
||
|
if ('\n' == c)
|
||
|
{
|
||
|
str[rd++] = c;
|
||
|
break;
|
||
|
}
|
||
|
else
|
||
|
str[rd++] = c;
|
||
|
}
|
||
|
if (0 == rd) return NULL;
|
||
|
else
|
||
|
{
|
||
|
str[rd] = '\0';
|
||
|
return str;
|
||
|
}
|
||
|
}
|