Use fgetc in while loops, use int instead of char
This commit is contained in:
committed by
Tatsuya Kinoshita
parent
6eb7866442
commit
c162b75317
14
Str.c
14
Str.c
@@ -530,11 +530,8 @@ Str
|
|||||||
Strfgets(FILE * f)
|
Strfgets(FILE * f)
|
||||||
{
|
{
|
||||||
Str s = Strnew();
|
Str s = Strnew();
|
||||||
char c;
|
int c;
|
||||||
while (1) {
|
while ((c = fgetc(f)) != EOF) {
|
||||||
c = fgetc(f);
|
|
||||||
if (feof(f) || ferror(f))
|
|
||||||
break;
|
|
||||||
Strcat_char(s, c);
|
Strcat_char(s, c);
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
break;
|
break;
|
||||||
@@ -546,11 +543,8 @@ Str
|
|||||||
Strfgetall(FILE * f)
|
Strfgetall(FILE * f)
|
||||||
{
|
{
|
||||||
Str s = Strnew();
|
Str s = Strnew();
|
||||||
char c;
|
int c;
|
||||||
while (1) {
|
while ((c = fgetc(f)) != EOF) {
|
||||||
c = fgetc(f);
|
|
||||||
if (feof(f) || ferror(f))
|
|
||||||
break;
|
|
||||||
Strcat_char(s, c);
|
Strcat_char(s, c);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
|
Reference in New Issue
Block a user