This is my homework for Accelerated C++ 3-3
~Count how many times each word appears after inputting a tons of strings using cin.
the code inside RandC.cpp works fine if it is inside main();
main.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
#include <vector>
#include <string>
#include "RandC.h"
using std:: vector;
using std:: string;
using std:: cin;
int main()
{
vector<string> Cstr;
vector<int> Cint;
string x ;
RandC( Cstr ,Cint );
}
Hi. For future notice, you can just edit your own post by clicking the edit button, no need to spam your own thread.
It would also help to know where it crashes, learn how to debug so you can find the line of code(s) where things go wrong. But I assume the problem can be solved by initializing the string in main.cpp.
1 2 3
vector<string> Cstr;
vector<int> Cint;
string x = " "; // Initialized to a whitespace
@coder777 Thanks ,that's the problem . I add comments on where the error occurred .
Yeah .the empty vector made my program crash !
@dhayden ,I will check that ,thanks