2
Recently I started learning about function strcat()
and developed the code below, but I’m encountering a Segmentation fault:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
char a[] ="sweet ";
char b[] = "home ";
char c[] = "alabama ";
strcat(a, b);
strcat(a, c);
printf("%s", a);
return 0;
}
Why does this mistake happen? How to avoid it?
Ok, thank you so much for the answer will help a lot.
– Gustavo Martins