AnsweredAssumed Answered

Basic question about strcpy with MCUxpresso:

Question asked by Marian Iordan on Dec 20, 2017
Latest reply on Dec 22, 2017 by Marian Iordan

Basic question about strcpy: I am using MCUxpresso IDE 10.0 for KL26z128 processor, and I am getting a compile error on following piece of code - need some help with it. 

 

376:  char LCD_TXT[2][21];
377:  strcpy(LCD_TXT[0], 'def');
378:  strcpy(LCD_TXT[1], 'tuv');

 

Description Resource Path Location Type
expected declaration specifiers or '...' before '\x646566' main.c /MKL26Z128xxx4_Project/source line 377 C/C++ Problem
expected declaration specifiers or '...' before '\x747576' main.c /MKL26Z128xxx4_Project/source line 378 C/C++ Problem
expected declaration specifiers or '...' before 'LCD_TXT' main.c /MKL26Z128xxx4_Project/source line 377 C/C++ Problem
expected declaration specifiers or '...' before 'LCD_TXT' main.c /MKL26Z128xxx4_Project/source line 378 C/C++ Problem
make: *** [source/main.o] Error 1 MKL26Z128xxx4_Project C/C++ Problem
recipe for target 'source/main.o' failed subdir.mk /MKL26Z128xxx4_Project/Debug/source line 18 C/C++ Problem

if changing as below (and corrected is as per Eric's comments - 12/21), output is slightly different, though still failing:

376:    char LCD_TXT[2][21];
377:    strcpy(char LCD_TXT[0], char "def");
378:    strcpy(char LCD_TXT[1], char "tuv");

Description Resource Path Location Type
expected ';', ',' or ')' before string constant main.c /MKL26Z128xxx4_Project/source line 377 C/C++ Problem
expected ';', ',' or ')' before string constant main.c /MKL26Z128xxx4_Project/source line 378 C/C++ Problem
make: *** [source/main.o] Error 1 MKL26Z128xxx4_Project C/C++ Problem
recipe for target 'source/main.o' failed subdir.mk /MKL26Z128xxx4_Project/Debug/source line 18 C/C++ Problem

Outcomes