How do I replace 1 or more characters ina char * array?


before start, sorry such novice question. new c , having difficulty getting head around strings , pointers.
i have spent last few days researching this, including trip library, , still cannot it.

how replace 1 or more characters in char * array?

here simple test sketch
code: [select]



void setup()
{
  serial.begin(9600);
  while (!serial) {
  ; // wait serial port connect. needed leonardo only
  }
 
 
serial.print("start\n");

char* menulist[10][21]   =  { '\0' };

*menulist[1] = "test";
*menulist[2] = "2222222222";
serial.print("menulist[1] = ");  serial.println( *menulist[1] );
serial.print("menulist[2] = ");  serial.println( *menulist[2] );
// above works fine.

//does not work - menulist[1] unchanged
*menulist[1][1] = '9';
serial.print("menulist[1] = ");  serial.println( *menulist[1] );

// not compile.  error says: lvalue required left operand of assignment
&menulist[1][1] = '9';

// not compile.  error says: invalid conversion 'char' 'char*'
*&menulist[1][1] = '9';


}


void loop() {;}




i understand errors getting don't know correct format is.


my actual application replace hh, mm , ss in menu option:

code: [select]

menulist[1] = "start time:00:00:00";
menulist[2] = "stop time: 00:00:00";



i can convert ints strings (hours, mins, secs) , want insert them menulist strings


any appreciated.


ps kind of string replace function marvellous...

strcpy()


Arduino Forum > Using Arduino > Programming Questions > How do I replace 1 or more characters ina char * array?


arduino

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62