Hi all,
why
#include<stdio. h>
#include<stdlib .h>
#include<string .h>
int main(void)
{
char *t[5]; /*= {"BASIC"};*/
strcpy(t[0],"BASIC");
printf("....%s" ,t[0]);
return EXIT_SUCCESS;
}
/* i am getting segmentation violation in lcc compiler*/
is not working whereas
int main(void)
{
char *t[5] = {"BASIC"};
/*strcpy(t[0],"BASIC");*/
printf("....%s" ,t[0]);
return EXIT_SUCCESS;
}
is working ?
Does this mean that while using strcpy the char pointer should
always be initialized ...?????
why
#include<stdio. h>
#include<stdlib .h>
#include<string .h>
int main(void)
{
char *t[5]; /*= {"BASIC"};*/
strcpy(t[0],"BASIC");
printf("....%s" ,t[0]);
return EXIT_SUCCESS;
}
/* i am getting segmentation violation in lcc compiler*/
is not working whereas
int main(void)
{
char *t[5] = {"BASIC"};
/*strcpy(t[0],"BASIC");*/
printf("....%s" ,t[0]);
return EXIT_SUCCESS;
}
is working ?
Does this mean that while using strcpy the char pointer should
always be initialized ...?????
Comment