Expand|Select|Wrap|Line Numbers
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- int main()
- {
- char* items[5];
- int i;
- for(i=0;i<5;i++)
- {
- char* temp = new char[11];
- strcpy(temp,"AB CD EFGH");
- items[i] = temp;
- printf("items is:%u\n",&items[i]);
- printf("strlen of items is:%d\n",strlen(items[i]));
- }
- items[5] = 0;
- char** item_ptr = items;
- while (*item_ptr != 0)
- {
- printf("item_ptr is:%u\n",*item_ptr);
- delete *item_ptr; //whether this is correct?
- //delete []*item_ptr; or this is correct?
- item_ptr++;
- }
- return 0;
- }