I'm running ubuntu on x86_32...and I keep getting segmentation fault while running this program.
#include<stdio.h>
#include<stddef.h>
char *memcp(char *dest, const char *src, size_t n)
{
char *dp = dest;
const char *sp = src;
while(n--)
*dp++ = *sp++;
return dest;
}
int main()
{
char *s = "abcde";
char *d;
char *r = memcp(d,s,6);
printf("%s",r);
return(0);
}
The problem with this code is that it is running on my friend's x86_64 machine on windows as well as ubuntu. Please help me out ..