>Ohh is this what you meant by initializing it as char *
Not quite:
Code:
/* pseudocode */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct test
{
char *name;
};
static void resize ( char * a )
{
char *temp;
if ( ( temp = realloc ( a, 13 * sizeof *a ) ) != NULL )
a = temp;
}
int main ( void )
{
struct test a;
if ( ( a.name = malloc ( 6 * sizeof a.name ) ) != NULL ) {
strcpy ( a.name, "Fooby" );
puts ( a.name );
resize ( a.name );
strcpy ( a.name, "Fooby Rules!" );
puts ( a.name );
free ( a.name );
}
return 0;
}
-Prelude