I have the below program written in C++:
#include <iostream>
using namespace std;
int main()
{
int age[5];
char name[5][10];
age[0]=10;
age[1]=20;
age[2]=30;
age[3]=25;
age[4]=40;
name[0]="abc";
name[1]="abc";
name[2]="abc";
name[3]="abc";
name[4]="abc";
cout<<name[0]<<" is "<<age[0]<<"years old";
cout<<"\n";
cout<<name[1]<<" is "<<age[1]<<"years old";
cout<<"\n";
cout<<name[2]<<" is "<<age[2]<<"years old";
cout<<"\n";
cout<<name[3]<<" is "<<age[3]<<"years old";
cout<<"\n";
cout<<name[4]<<" is "<<age[4]<<"years old";
cout<<"\n\n";
system("PAUSE");
}
When I compile and run it, I get these errors:
error C2440: '=' : cannot convert from 'const char [3]' to 'char [10]' There is no context in which this conversion is possible
error C2440: '=' : cannot convert from 'const char [2]' to 'char [10]' There is no context in which this conversion is possible
error C2440: '=' : cannot convert from 'const char [2]' to 'char [10]' There is no context in which this conversion is possible
error C2440: '=' : cannot convert from 'const char [2]' to 'char [10]' There is no context in which this conversion is possible
error C2440: '=' : cannot convert from 'const char [2]' to 'char [10]' There is no context in which this conversion is possible
I am running MSVC 2008 under Windows 7. I have tried many possible solutions but I failed in fixing this. Any help would be appreciated,