H
herrcho
#include <stdio.h>
#include <string.h>
int main()
{
char *imsip;
strcpy(imsip, "archie");
return 0;
}
the above code causes error which i expected.. as the object imsip is
not initalized.
But the below one executes alright..
#include <stdio.h>
#include <string.h>
int main()
{
struct msg
{
char p1[30];
char *p2;
} myptrs;
strcpy(myptrs.p1, "Wonderful day");
strcpy(myptrs.p2, "Beautiful Day");
puts(myptrs.p1);
puts(myptrs.p2);
return 0;
}
I have no idea how come the second one executes alright..
Thanks in advance..
#include <string.h>
int main()
{
char *imsip;
strcpy(imsip, "archie");
return 0;
}
the above code causes error which i expected.. as the object imsip is
not initalized.
But the below one executes alright..
#include <stdio.h>
#include <string.h>
int main()
{
struct msg
{
char p1[30];
char *p2;
} myptrs;
strcpy(myptrs.p1, "Wonderful day");
strcpy(myptrs.p2, "Beautiful Day");
puts(myptrs.p1);
puts(myptrs.p2);
return 0;
}
I have no idea how come the second one executes alright..
Thanks in advance..