convert to upper

have the following:

1
2
3
4

char input;
cin.getline(input);


trying to check if lowercase input, trying to make it become uppercase automatically instead...

but i keeps getting this error

abc.cpp: In function ‘int main(int, char**)’:
abc.cpp:94:8: error: invalid conversion from ‘char*’ to ‘char

i tried alot of combinations including toupper #include <cctype> but stil couldn't get the results i want, any idea why ?
Last edited on
1
2
3
4
5
for(int i = 0 ; i < strlen(input) ; i++)
	{
		ch = toupper(input[i]);
		cout<<(char)ch;
	}
thanks but still same issue.

anyw i've resolved it already
Last edited on
hi,
your code:
1
2
char input;
cin.getline(input);


cin.getline() function reads chars until '\n' and removes '\n' (also you are missing length as second parameter)
you'll have to use cin.get() OR
change input variable to char [] or string.

then use toupper function to change the fisrt letter, or use for loop to change all chars as bluecoder described.

cheers.
Last edited on
Original Post:
wantyoubadly wrote:

have the following:

1
2
char input;
cin.getline(input);


trying to check if lowercase input, trying to make it become uppercase automatically instead...

but i keeps getting this error

abc.cpp: In function ‘int main(int, char**)’:
abc.cpp:94:8: error: invalid conversion from ‘char*’ to ‘char

i tried alot of combinations including toupper #include <cctype> but stil couldn't get the results i want, any idea why ?


wantyoubadly has the tendency to remove the original post, so I am preserving it here in the (very likely) event that this happens here too.
Topic archived. No new replies allowed.