Mar 31, 2010 at 6:42am UTC
I am not able to access b[i] in the for loop .
char b[30]= " initialize";
if(S==1)
b[] = "SN 2 X 0.001\r MN 2 X 1\r";
else if( S==2)
b[] = "SN 2 X 0.005\r MN 2 X 1\r";
else if(S==3)
b[] = "SN 2 X 0.01\r MN 2 X 1\r";
else if(S==4)
b[] = "SN 2 X 0.02\r MN 2 X 1\r";
else if(S==5)
b[] = "SN 2 X 0.05\r MN 2 X 1\r";
else if(S==6)
b[] = "SN 2 X 0.1\r MN 2 X 1\r";
else if(S==7)
b[] = "SN 2 X 0.2\r MN 2 X 1\r";
else if(S==8)
b[] = "SN 2 X 0.5\r MN 2 X 1\r";
else if(S==9)
b[] = "SN 2 X 1\r MN 2 X 1\r";
else
b[] = "SN 2 X 5\r MN 2 X 1\r";
for( int i=0; i< 40 ;i++)
{
char a = b[i];
xplus0.WriteByte(a);
if ( a == '\0')
break;
}
Mar 31, 2010 at 6:37pm UTC
@choisum: at the cost of coding errors. "const char* b[] = ... " is what you want. Otherwise you may accidentally try "strcpy(b[0], "foo"); " and the compiler would let you (though your OS might not).
You don't have this problem with strings.
Mar 31, 2010 at 11:45pm UTC
yup, const is useful here...
Apr 1, 2010 at 5:14pm UTC
but b is not be changed:it is const
Apr 8, 2010 at 4:29am UTC
thanks for discussion guys