Skip to content

Commit ef92784

Browse files
author
Chad Sharp
authored
Cast to unsigned char before calling isspace
1 parent 731a152 commit ef92784

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/cs50.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ double get_double(void)
131131
}
132132

133133
// return a double if only a double was provided
134-
if (strlen(line) > 0 && !isspace(line[0]))
134+
if (strlen(line) > 0 && !isspace((unsigned char) line[0]))
135135
{
136136
char *tail;
137137
errno = 0;
@@ -169,7 +169,7 @@ float get_float(void)
169169
}
170170

171171
// return a float if only a float was provided
172-
if (strlen(line) > 0 && !isspace(line[0]))
172+
if (strlen(line) > 0 && !isspace((unsigned char) line[0]))
173173
{
174174
char *tail;
175175
errno = 0;
@@ -207,7 +207,7 @@ int get_int(void)
207207
}
208208

209209
// return an int if only an int (in range) was provided
210-
if (strlen(line) > 0 && !isspace(line[0]))
210+
if (strlen(line) > 0 && !isspace((unsigned char) line[0]))
211211
{
212212
char *tail;
213213
errno = 0;
@@ -241,7 +241,7 @@ long long get_long_long(void)
241241
}
242242

243243
// return a long long if only a long long (in range) was provided
244-
if (strlen(line) > 0 && !isspace(line[0]))
244+
if (strlen(line) > 0 && !isspace((unsigned char) line[0]))
245245
{
246246
char *tail;
247247
errno = 0;

0 commit comments

Comments
 (0)