The error is due to the fact that you are mistaken in strcat() . Check out the strcat() prototype:
char *strcat(char *dest, const char *src);
But you pass char as the second argument, which is obviously wrong.
Use snprintf() instead.
char str[1024] = "Hello World"; char tmp = '.'; size_t len = strlen(str); snprintf(str + len, sizeof str - len, "%c", tmp);
As the OP commented:
This was just an example from Hello World to describe the problem. It should be empty, like the first in my real program. The program will fill it out later. The problem is simply to add char / int to a char Array
In this case, snprintf() can easily handle the "adding" of integer types to the char buffer. The advantage of snprintf() is that it is more flexible to combine different data types into a char buffer.
For example, to combine a string, char and int:
char str[1024]; ch tmp = '.'; int i = 5; // Fill str here snprintf(str + len, sizeof str - len, "%c%d", str, tmp, i);
source share