I am using the CS50 appliance from Harvard and trying to make a character lowercase. I am trying to use the tolower()
function but when I try to use it I get the message implicit declaration of function 'tolower' is invalid in C99
. Anyone care to elaborate on why I would be getting this message. I have included stdio.h
as well as string.h
.
Asked
Active
Viewed 1.3k times
8

Jonathan Leffler
- 730,956
- 141
- 904
- 1,278

ChapmIndustries
- 1,401
- 4
- 17
- 19
-
1You didn't include the header and, in C99, functions are not assumed to be valid and return an int if there is no definition. – Ed S. Sep 27 '12 at 03:21
3 Answers
20
To use tolower
in C99, use #include <ctype.h>
It is not an I/O function and it doesn't operate on strings (it operates on characters), so it's not in stdio
or string
.

Gabe
- 84,912
- 12
- 139
- 238
-
Well this has corrected the problem of calling an unidentified function but now when I try to just say `character[0]="A";` i get trouble. Any ideas? Says something about pointers and integers. For reference I declared `char character[2];`. – ChapmIndustries Sep 27 '12 at 03:22
-
2character[0] = 'A' should work. By doing character[0] = "A", you are trying to assign a string to a character, which is not allowed. – Jay Sep 27 '12 at 03:25
-
@ChapmIndustries "A" is `const char *`, so the assignment is dealign with `const char *`, a pointer type, assigned to `char`, an integral type. – obataku Sep 27 '12 at 03:48
5
tolower
is defined in ctype.h
. That is the file you should be including:
#include <ctype.h>
will solve your problem.

epsalon
- 2,294
- 12
- 19