Can´t print string

Hello,
I`ve tryed evrything!
This is my code
1
2
3
4
5
6
7
8
9
10
11
void genera_datos(multimap<equipo,jugador> liga){

	equipo equipa;
	for (int i=0;i<3;i++)
	{
		int randomChar = rand()%26;
		equipa[i]='A' + randomChar;
		cout << equipa[i] << endl;
	}
	cout << equipa << endl;
}


The main :
1
2
3
4
5
6
7
8
9
10
 int main()
{
 multimap<equipo,jugador> liga;

 srand ( time (NULL) );
 cout << "Start function" << endl;
 genera_datos(liga);
 cout << "End function" << endl;
 getch();
}


and the header :
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <map>
#include <string>
#include <limits>
#include <list>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
using namespace std;
typedef string equipo;



My problem is that this code wont print the string when i call cout << equipa << endl;
I add that i use Eclipse with MinGW as a compiler.
Thanks in advance.
equipa has a size of 0 in your function. You need to create space to insert characters.
You can do that using the proper constructor or using push_back

http://www.cplusplus.com/reference/string/string/string/
http://www.cplusplus.com/reference/string/string/push_back/
Thanks a lot for your answer!
Dam what easy it was...stupid me..it seemes that i must make a reboot!
Topic archived. No new replies allowed.