I'm Trying to do some simple c programming that will return the char value. The program is running with no error but, the output of the expected string does not appear. What I expected it will return the Halloworld when i run it.
#include <stdio.h>
#include <string.h>
char screen(char c[]);
int main(){
char b[] = "Hallo";
//screen(b);
printf("%s",screen(b));
}
char screen(char c[]){
strcat(c, "world");
return c;
}
char[]tocharand I would expect a compile-time error from that.bis a constant object without enough space for any more data to be appended to it, which means this program is undefined behavior and anything could happen, including nothing at all.-Wall -Werroror whatever the equivalent in your compiler would be: don't just ignore a compiler warning like that.) If you don't understand that warning, then that's a good question in itself (but I'm pretty sure it's been asked and answered thoroughly already here somewhere).