next up previous
Next: In class exercises Up: Pointers Previous: Pointers

Examples



char *hello;
strcpy(hello, "Hello World"); // Error

char *hello;
hello = new char[20];
strcpy(hello, "Hello World"); // Correct
delete [] hello;

char hello[]="Hello World";
char *h2;
h2 = hello;
delete [] hello;              // Error

int x=5;
int *y;
y=&x;                         // Correct



Eric Breimer
9/13/1999