I have small program using structure.The elements in the structure are char arrays.After filling the structure , I am trying to print the values , but values are not printng correctly.
How to solve this problem?
typedef struct
{
char cName[3];
char cAddress[3];
char cLocation[3];
char cCountry[3];
}MSG;
int main(int argc, char* argv[])
{
MSG msg;
strcpy(msg.cName,"Mik"
strcpy(msg.cAddress,"Ray"
strcpy(msg.cLocation ,"LO1"
strcpy(msg.cCountry,"CAN"
cout<<msg.cName<<endl;
cout<<msg.cAddress<<endl;
cout<<msg.cLocation<<endl;
cout<<msg.cCountry<<endl;
return 0;
}
How to solve this problem?
typedef struct
{
char cName[3];
char cAddress[3];
char cLocation[3];
char cCountry[3];
}MSG;
int main(int argc, char* argv[])
{
MSG msg;
strcpy(msg.cName,"Mik"
strcpy(msg.cAddress,"Ray"
strcpy(msg.cLocation ,"LO1"
strcpy(msg.cCountry,"CAN"
cout<<msg.cName<<endl;
cout<<msg.cAddress<<endl;
cout<<msg.cLocation<<endl;
cout<<msg.cCountry<<endl;
return 0;
}