sorry i modified the code now:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main()
{
int i=0;
char** f=NULL;
char* ff=NULL;
ff="abcd";
f=( char**)malloc ((i + 1) * sizeof (char *)+5);
f[0]=ff;
// strcpy(f[0],ff); (this again giving same error)
strncat(f[0],"efg",3);
printf("f : %s",f[0]);
}
I am getting some unhandled exception, Access violation writing error. Can anyone explain me the error I did here.
NOTE : sorry i modified the code now:
Thanks for the answers
you are setting f<-ff
ff points to the start of a constant char[] (“abcd”)
and then you change the value of *f (which is exactly *ff) thus – access violation.