copy the letters one by one to the message string
message[0]=str1[0];
message[1]=str2[0];
message[2]=str3[0];
message[3]=str4[0];
message[4]=str5[0];
message[5]=str6[0];
message[6]=str7[0];
message[7]=str8[0];
message[8]=str9[0];
message[9]=str10[0];
unsigned char *ptr[10];
ptr[1]=str1[0];
.
.
.
ptr[9]=str10[0];
i=0;
while(i<9)
message[i]=*ptr[i++];
You can use string concatenation like
message = str1 + str2 + str3 + str0;
individual array for single character storage is not an efficient way...
this may help you. i am not sure ! :-?
Code:unsigned char *ptr[10]; ptr[1]=str1[0]; . . . ptr[9]=str10[0]; i=0; while(i<9) message[i]=*ptr[i++];
ptr[0]=[COLOR="#FF0000"]&[/COLOR]str1[0];
ptr[0]=str1; // the same as &str1[0]
unsigned char getKeyboard(){
do {
if (Ps2_Key_Read(&keydata, &special, &down)) {
if (down && !special && keydata) {
if(keydata==97){kb=97;} //a
if(keydata==98){kb=98;} //b
if(keydata==99){kb=99;} //c
if(keydata==100){kb=100;} //d
if(keydata==101){kb=101;} //e
if(keydata==102){kb=102;} //f
if(keydata==103){kb=103;} //g
if(keydata==104){kb=104;} //h
if(keydata==105){kb=105;} //i
if(keydata==106){kb=106;} //j
if(keydata==107){kb=107;} //k
if(keydata==108){kb=108;} //l
if(keydata==109){kb=109;} //m
if(keydata==110){kb=110;} //n
if(keydata==111){kb=111;} //o
if(keydata==112){kb=112;} //p
if(keydata==113){kb=113;} //q
if(keydata==114){kb=114;} //r
if(keydata==115){kb=115;} //s
if(keydata==116){kb=116;} //t
if(keydata==117){kb=117;} //u
if(keydata==118){kb=118;} //v
if(keydata==119){kb=119;} //w
if(keydata==120){kb=120;} //x
if(keydata==121){kb=121;} //y
if(keydata==122){kb=122;} //z
} } Delay_ms(5);
return kb;
} while (1);
}
if (down && (keydata==13)){ break;} // enter
#define MAX 100 // maximum number of letters the array will hold
int main()
{
unsigned char letter; // uchar to hold the current letter
unsigned char letterArray[MAX]; // array to hold the string
int index= 0; // start with 0 index
while(1) {
letter= getKeyboard(); // get letter
if(letter!= 13)
letterArray[index++]= letter; // insert next char
else {
letterArray[index]= '\0'; // terminate current string
// lcd printing code here to print 'letterArray'
// ...
index= 0; // reset index to start again
}
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?