c++ - How to copy a string into a char array with strcpy -
i trying copy value char.
my char array is
char sms_phone_number[15];
by way, tell me if should write (what benefic/difference?)
char * sms_phone_number[15]
below displays string: "+417611142356"
splitedstring[1]
and want give value sms_from_number
// strcpy(sms_from_number,splitedstring[1]); // op's statement strcpy(sms_phone_number,splitedstring[1]); // edit
i've got error, think because splitedstring[1] string, isn't?
sim908_cooking:835: error: invalid conversion 'char' 'char*'
so how can copy correctely. tried sprintf without success.
many thank help. cheers
i declare spliedstring this
// slitstring #define nbvals 9 char *splitedstring[nbvals];
i have function splitstring("toto,+345,titi",slitedstring)
void splitstring(char *ligne, char **splitedstring) { char *p = ligne; int = 0; splitedstring[i++] = p; while (*p) { if (*p==',') { *p++ = '\0'; if (i<nbvals){ splitedstring[i++] = p; } } else { p++; } } while(i<nbvals){ splitedstring[i++] = p; } }
if splitedstring display, display this
for(int i=0;i<4;i++){ serialprint(i);serial.print(":");serial.println(splitedstring[i]); } //0:toto //1:+4176112233 //2:14/09/19
i declared , want copy..
char sms_who[15]; char sms_phone_number[15]; char sms_data[15]; //and want copy strcpy(sms_who,splitedstring[0] strcpy(sms_phone_number,splitedstring[1] strcpy(sms_date,splitedstring[2]
i know, confused char , pointer * :o(
Comments
Post a Comment