I am writing a program that takes a word, sends it to an array and uses that information to perform various library functions to manipulate it. The one I am currently on is I need to use the toupper library function to convert a word in an array to all capital letters. I am running into some problems, however as it is just not working.
I run the function I have using it through my head as if I were the compiler and everything seems alright, but for some reason it does not work. Further more, when I was experimenting with toupper earlier with single char letters, to get a feel for using it, it was returning an int, which I believe was the ascii dec version of what I was sending it, or the ascii dec version of what it was supposed to be converted to.
I would, of course like help with my initial problem, but if anyone could explain toupper better that would also be helpful, as the resources on this site are confusing me verses what my programming book tells me about the toupper function.
// Programmed by Kevin Seidel
// String Manipulation lab
// Part B manipulating words
void upper(char );
int SIZE = 10;
char wArray [SIZE];
cout << "Please enter a single word" << endl;
cout << "The word you entered is: " << wArray << endl;
cout << "\nThe length of your word is: " << strlen(wArray) <<" Letters" << endl;
void upper(char array )
int i = 0;
while(array[i] != '\0')
cout << array[i];
cout <<" is your word in all caps" << endl;
You call the function toupper() but don't do anything with the result.
You should assign the result to something, like this: array[i] = toupper(array[i]);
Other points. On line 14, SIZE should be a constant.
(the value is also a bit miserly, there are many words of more than 9 letters). constint SIZE = 50;
Standard C++ requires that the array on line 15 is specified using a constant, hence the use of const on line 14.