pellyhawk
August 11th, 2012, 08:24 PM
I got very weird results with two similar code block.
int communication;
char communication_str[][12]=
{
"GPRS Offline",
"GPRS Idle",
"GPRS COMM",
"---"
};
for (communication = 0; communication < 4; communication++)
{
printf("communication = %d %s\n", communication, communication_str[communication]);
}
got:
communication = 0 GPRS OfflineGPRS Idle
communication = 1 GPRS Idle
communication = 2 GPRS COMM
communication = 3 ---
If I modified the code block above:
int communication;
char communication_str[][12]=
{
"GPRS Off",
"GPRS Idle",
"GPRS COMM",
"---"
};
for (communication = 0; communication < 4; communication++)
{
printf("communication = %d %s\n", communication, communication_str[communication]);
}
got:
communication = 0 GPRS Off
communication = 1 GPRS Idle
communication = 2 GPRS COMM
communication = 3 ---
Why I got different result? Thanks.
int communication;
char communication_str[][12]=
{
"GPRS Offline",
"GPRS Idle",
"GPRS COMM",
"---"
};
for (communication = 0; communication < 4; communication++)
{
printf("communication = %d %s\n", communication, communication_str[communication]);
}
got:
communication = 0 GPRS OfflineGPRS Idle
communication = 1 GPRS Idle
communication = 2 GPRS COMM
communication = 3 ---
If I modified the code block above:
int communication;
char communication_str[][12]=
{
"GPRS Off",
"GPRS Idle",
"GPRS COMM",
"---"
};
for (communication = 0; communication < 4; communication++)
{
printf("communication = %d %s\n", communication, communication_str[communication]);
}
got:
communication = 0 GPRS Off
communication = 1 GPRS Idle
communication = 2 GPRS COMM
communication = 3 ---
Why I got different result? Thanks.