Skip to content

Commit 88b2b26

Browse files
authored
Update getfloat.c
Added one more condition "&& (c != '.')" to allow the user to type ".1" and let the program assume it is 0.1
1 parent d7272a2 commit 88b2b26

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

chapter_5/exercise_5_02/getfloat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int getfloat(float *pn)
4646
while (isspace(c = getch()))
4747
;
4848

49-
if (!isdigit(c) && c != EOF && c != '+' && c != '-')
49+
if (!isdigit(c) && c != EOF && c != '+' && c != '-' && c != '.')
5050
{
5151
ungetch(c);
5252
return 0;

0 commit comments

Comments
 (0)