hi everyone . i am new to the fourm and i was trying to compile a file using gcc to catenate two string but keep getting a segmentation fault
this is the source code
Code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
int x;
char *pring,*ding;
printf("\n enter any string ");
scanf("%s",pring);
printf("\n enter another string");
scanf("%s",ding);
x=sizeof(pring)+sizeof(ding)+22;
pring=realloc(pring,x);
strcat(pring,ding);
printf("\n%s",pring);
return 0;
}
This is the message i get when i try to debug it with gdb :
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7aade97 in _IO_vfscanf () from /lib/libc.so.6
can anyone help me out with this ??