New to C here. Was trying out strcat and thought my code should give error but it works fine.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char* argv[]){
char string[] = "string!";
char* concat = (char*)malloc(sizeof(char));
strcat(concat,string);
printf("%s\n", concat);
free(concat);
}
As a matter of fact, I am able to access memory like printf("%c\n", *(concat +1232));
which should throw error, right?
I was trying out string functions and seeing doing what will give me what errors. I thought that the above code would have given error but it doesn't. Is my understanding of strcat wrong?