I am writing an exchange program and I have a char array that holds another 6 char arrays. The program works fine except for one thing: when I try to print the arrays' values, it prints only the first letter.
Maybe the code isn't right, but I didn't find another way to make this exchange. Actually I think the problem is in pointers that point to that arrays, but again I am not sure.
Here is the code:
#include <iostream>
#include <string>
#include <fstream>
#include <stdlib.h>
using namespace std;
int main(int argc, char* argv[])
{
cout<<"EXCHANGE POKEMON:"<<endl;
char a[100]="PIKACHU", b[100]="CHARMELEON", c[100]="GEODUDE", d[100]="GYARADOS", e[100]="BUTTERFREE", f[100]="MANKEY", tmp[100];
char t[6] = {*a,*b,*c,*d,*e,*f};
while(1)
{
for(int i = 0; i < 6; i++)
{
cout << i << ") " << t[i] <<endl;
}
cout<<endl<<"Choose a pokemon:";
int x, y;
cin>>x;
if(x == -1)
{
exit(0);
}
cout << "Choose a pokemon to exchange with:";
cin>>y;
*tmp = t[x];
t[x] = t[y];
t[y] = *tmp;
}
}
std::stringto represent strings (andstd::swapto swap them)?