Dec 31, 2013 at 10:48pm UTC
I have to do the following
Read a sequence of words from cin and store the values a
vector. After you’ve read all the words, process the vector and change
each word to uppercase. Print the transformed elements, eight words to a
line.
and for some reason there is no output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include <iostream>
#include <vector>
using std::cout; using std::cin; using std::endl;
using std::vector; using std::string;
int main()
{
string input, test;
vector<string> container;
unsigned counter = 0;
while (cin >> input) {
container.push_back(input);
for (auto &c : container[counter]) {
c = isupper(c);
}
cout << container[counter];
++counter;
}
return 0;
}
Last edited on Dec 31, 2013 at 11:13pm UTC
Dec 31, 2013 at 11:01pm UTC
int isupper ( int c );
Check if character is uppercase letter
Checks if parameter c is an uppercase alphabetic letter.
Return Value
A value different from zero (i.e., true) if indeed c is an uppercase alphabetic letter. Zero (i.e., false) otherwise.
Dec 31, 2013 at 11:03pm UTC
Oh, thought that would convert it to upper case. How do I convert that character into a capital?
Dec 31, 2013 at 11:03pm UTC
You probably meant toupper rather than isupper .
Dec 31, 2013 at 11:12pm UTC
Oh yes yes i did :/
Thanks guys,