foo not a pointer, so you do not want to use it as one. You also do not need to check if the character is an uppercase letter before using tolower - it converts upper and lower case and leaves other characters unchanged. You probably want something like:
for (i=0; foo[i]; i++) foo[i] = tolower((unsigned char)foo[i]);
Note that when you call tolower (and toupper , isalpha , etc.), you really need to make your input unsigned char . Otherwise, many (most?) Characters outside the main English / ASCII character set will often lead to undefined behavior (for example, in the typical case, the most accented characters will appear as negative numbers).
Aside, when you read a line, you do not want to use scanf with %s - you always want to specify the length of the line, for example: scanf("%19s", foo); assuming SIZE == 20 (i.e. you want to specify one size smaller. Alternatively, you can use fgets , for example fgets(foo, 20, infile); Note that with fgets you specify the size of the buffer, not one less you do with scanf (and a company like fscanf).
source share