Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 10 months ago.
problems with strcat()
Hello, Im' having an issue with my program.
void inserisciPassword(char matrix[PASSWORDS][MAX]) { char pass[10]; char buffer[PASSWORDS]; int cnt=0; strcpy(pass,"password"); while(cnt<100){ sprintf(buffer,"%d",cnt); strcat(matrix[cnt],buffer[cnt]); } }
it gives me this error: Error: Argument of type "char" is incompatible with parameter of type "const char *" in "main.cpp", Line: 21, Col: 29
Could you please help me?
1 Answer
7 years, 10 months ago.
strcat takes two character arrays as parameters http://www.cplusplus.com/reference/cstring/strcat/
strcat(matrix[cnt],buffer[cnt]);
Here, you are passing in a character array(matrix[cnt]
) and a character(buffer[cnt]
). As buffer
is a character array, buffer[cnt]
will give you the character at position cnt
. As an aside, you have not initialized the buffer, so you are not concatenating anything to matrix[cnt]
.