Skip to content

Commit 9fbf58b

Browse files
authored
Merge pull request #70 from crossroads1112/master
Cast to unsigned char before calling isspace
2 parents 2bd946a + ef92784 commit 9fbf58b

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
@@ -137,7 +137,7 @@ double get_double(string prompt)
137137
}
138138

139139
// return a double if only a double was provided
140-
if (strlen(line) > 0 && !isspace(line[0]))
140+
if (strlen(line) > 0 && !isspace((unsigned char) line[0]))
141141
{
142142
char *tail;
143143
errno = 0;
@@ -183,7 +183,7 @@ float get_float(string prompt)
183183
}
184184

185185
// return a float if only a float was provided
186-
if (strlen(line) > 0 && !isspace(line[0]))
186+
if (strlen(line) > 0 && !isspace((unsigned char) line[0]))
187187
{
188188
char *tail;
189189
errno = 0;
@@ -229,7 +229,7 @@ int get_int(string prompt)
229229
}
230230

231231
// return an int if only an int (in range) was provided
232-
if (strlen(line) > 0 && !isspace(line[0]))
232+
if (strlen(line) > 0 && !isspace((unsigned char) line[0]))
233233
{
234234
char *tail;
235235
errno = 0;
@@ -271,7 +271,7 @@ long long get_long_long(string prompt)
271271
}
272272

273273
// return a long long if only a long long (in range) was provided
274-
if (strlen(line) > 0 && !isspace(line[0]))
274+
if (strlen(line) > 0 && !isspace((unsigned char) line[0]))
275275
{
276276
char *tail;
277277
errno = 0;

0 commit comments

Comments
 (0)