#include <iostream>
#include <string>
usingnamespace std;
struct Teams
{
string name;
string type;
int power;
};
void name_teams (Teams names [], int num)
{
for (int i = 0; i < num; i++)
{
cout <<"Player, what is your team name?"<<endl;
cin >>names[i].name;
}
}
int main()
{
Teams names;
name_teams (names, 2 );
cout <<names[0].name;
cout <<names[1].name;
}
debug is :
1 2 3 4 5 6 7 8
mingw32-g++.exe -Wall -fexceptions -g -c C:\Users\Mcodes\Desktop\game\main.cpp -o obj\Debug\main.o
C:\Users\Mcodes\Desktop\game\main.cpp: In function 'int main()':
C:\Users\Mcodes\Desktop\game\main.cpp:25:26: error: cannot convert 'Teams' to 'Teams*' for argument '1' to 'void name_teams(Teams*, int)'
C:\Users\Mcodes\Desktop\game\main.cpp:26:19: error: no match for 'operator[]' in 'names[0]'
C:\Users\Mcodes\Desktop\game\main.cpp:27:19: error: no match for 'operator[]' in 'names[1]'
Process terminated with status 1 (0 minute(s), 0 second(s))
3 error(s), 0 warning(s) (0 minute(s), 0 second(s))
merely trying to freshen up on pointers, structures, arrays, functions and how they can work together but it seems I've grown quite rusty in my c++ coding.
If somebody could help tell me where I'm wrong in this that would be great, I'm trying to create two structures and have them named by input