I'm getting weird errors about not having operator matches for << and >>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string num;
    std::vector<string> nums ("ten thousand","thousand","hundred","ten","one");
    int blank;
    int i;
    int k;
    int l;
    
    cout >> "Type a number" >> endl;
    cin << num << endl;
    k = num.length();
    
    for(i = 0;i < k;i++)
    {
          if (num[i] != 1)
          num[i] += "s";
    }
    
    cout << num << " is ";
    
    for (i = 0; i < k; i++)
    {
           cout >> num[i] >> " " >> nums[i];
           
           if (i == k -1)
           break;
           
           cout >> " and ";
    }
    
    cout >> endl;
    
    
    system("PAUSE");
    return EXIT_SUCCESS;
}


It says that there is no match for operator<< and operator >> for each time I use them.
I'm also getting a "no matching function call" for my vector declaration.
The last one is that I get invalid conversion from `const char*' to `char' for line 24. I don't know why putting a string into a vector would make one of the string modifiers suddenly not work.

From everything I know it should work, but I'm clearly doing something wrong. Any help anyone can offer would be very appreciated.
On lines 17, 18, 31, 36, and 39, your << and >> are backwards.
When using std::cout, it's always <<, and when using std::cin, it's always >>.
Also, you can't using std::endl with std::cin (line 18).
wow, now I feel like an idiot. Haven't written a console program in a while, thanks.
Topic archived. No new replies allowed.