seems like there should be a simple way to do this but i can't seem to figure it out.
Printable View
seems like there should be a simple way to do this but i can't seem to figure it out.
Code:#include <string>
int main (void)
{
char lpStr[256] = "Hi there";
std::string str = lpStr;
return 0;
}
my problems a bit more complicated than that.
just thought i was missing something easy.
hopefuly these snipets will help you to see my problem.
what i'm tring to do is pass a pointer to an array of strings
and populate it with an array of char arrays.
DStruct.path is part of a struct:Code:void pkrEdit::GetDirs(string *dirs[])
{
for(int i = 0; i < HStruct.num_dirs; i++)
{
dirs[i] = DStruct[i].path;
}
}
seems like it should work but my compiler keep throwing the same exeption:Code:typedef struct PK_DIR_STRUC
{
char path[32];
int file_offset;
int file_count;
}
error C2440: '=' : cannot convert from 'char [32]' to 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *'
sorry i wasn't more clear the first time.
not extremely clear. but you could try a cast to (char *).
Well i figured it out... turned out it was a misplaced new statment elsewhere in the code. thanks for trying though.