cannot print result

hi all,
i really new in c++ prog.
need help because my prog didnt print the output?
i try it for about half day.
hope to have quick solution.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
}
vector <string> result(4);

cout << "" << result[0]<< " " << result[1]<< " " << result[2]<< " " << result[3]<< endl;

}

/*---------------------------------------------------------------------------------------*/


vector <string> Guesscode(vector <string> answer, vector <string> codegenerate)
{

vector <string> result(4);

/*some function here*/




}
Last edited on
On line 73: you an vector with 4 empty strings. I guess that you want this:

1
2
3
4
5
vector <string> result = Guesscode(answer, codegenerate);

cout << "" << result[0]<< " " << result[1]<< " " << result[2]<< " " << result[3]<< endl;

}


usually it's better to use vector, but in this case where you have an exact number of elements which does not change it's probably better to use basic array
i have tried it but still no luck.
still dont have any output printed.
after put all the input the output is still not there.
take a look at this:

http://www.cplusplus.com/reference/vector/vector/vector/

on line 90 you use the fill constructor:
Constructs a container with n elements. Each element is a copy of val.


so you have already 4 empty elements. If you push_back() another value it's appended to the empty value as the element 4, 5, etc. So on line 75 you get only the first empty elements.
To solve that remove (4) on line 90
thanks mate.
both of you help a lot.
cheers.
both of you help a lot.
hm, yes.
The first was me
The second was myself
And now I
so altogether three;)
erkk, didnt notice same person.
sory mate.
my bad
need to remove some part of it.
and make some changes.
worry detect as plagiarism in uni.
Topic archived. No new replies allowed.