I wonder if that is correct, in ANSI C:
char *mystring;
mystring = "helloworld ";
or I should always proceed in this other, thougher, way:
char *mystring;
if( NULL == ( mystring = malloc( strlen( "helloworld ") ) ) )
{
printf("error\n ");
}
else
{
strcpy( mystring, "helloworld " );
}
Thanks!
char *mystring;
mystring = "helloworld ";
or I should always proceed in this other, thougher, way:
char *mystring;
if( NULL == ( mystring = malloc( strlen( "helloworld ") ) ) )
{
printf("error\n ");
}
else
{
strcpy( mystring, "helloworld " );
}
Thanks!
Comment