XINU
Main Page
Related Pages
+
Data Structures
Data Structures
Data Structure Index
+
Data Fields
+
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Files
File List
+
Globals
+
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
+
Variables
_
a
b
c
d
e
f
g
i
l
m
n
p
q
r
s
t
u
y
+
Typedefs
b
d
e
f
g
i
m
p
q
s
u
v
y
Enumerations
Enumerator
+
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
lib
fgets.c
Go to the documentation of this file.
1
5
#ifndef NULL
6
#define NULL 0
8
#endif
9
11
extern
int
getc
(
int
);
12
25
char
*
fgets
(
char
*s,
int
n,
int
dev)
26
{
27
int
c = 0;
28
char
*cs;
29
30
cs = s;
31
32
/* Read characters until maximum read length, */
33
/* end of line, or end of file */
34
while
((--n > 0) && ((c =
getc
(dev)) >= 0))
35
{
36
*cs++ = c;
37
if
((
'\n'
== c) || (
'\r'
== c))
38
{
39
break
;
40
}
41
}
42
43
/* Check for EOF or empty string */
44
if
((c < 0) && (cs == s))
45
{
46
return
NULL
;
47
}
48
49
/* Terminate string and return */
50
*cs++ =
'\0'
;
51
return
s;
52
}
fgets
char * fgets(char *s, int n, int dev)
デバイス(ファイル)から文字列を読み込む。
Definition:
fgets.c:25
NULL
#define NULL
NULLを示す値
Definition:
fgets.c:7
getc
int getc(int)
デバイスから1Byte読み込むgetc()のextern宣言
Definition:
getc.c:9
Generated by
1.8.13