• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# How would I fix this?

## Recommended Posts

I''m trying to say string **sp = new string[limit]; but I get this error: error C2440: ''initializing'' : cannot convert from ''std::string *'' to ''std::string ** '' So how would I fix it, and more over, why is it saying that? If i try and break it up: string **sp; *sp = new string[limit]; My stack gets corrupted because sp doesnt point to anything. So just for fun I tried this: string location; string **sp = &location; *sp = new string[limit]; But it couldn''t do a pointer-pointer to a string, change it to this: string *location; string **sp = &location; *sp = new string[limit]; Works but then I get memory errors again. So how would I go about this?

##### Share on other sites
You have to iterate.

  string **sp = new string*[20];for(int i = 0; i < 20; i++)    sp[i] = new string;

-----------------------------
Ahh thanks. I tried something similiar to that but did it wrong.

I tried string **sp = new *string[limit];

Which didn''t work. Thanks for your help.

• ### Forum Statistics

• Total Topics
627708
• Total Posts
2978730

• 21
• 14
• 12
• 22
• 35