This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Strcopy

Hello.

I am trying to make parser for string.
string contains double number so I am using atof() to make double from it. but when I try it makes something strange when use strcopy() to make char* from string. Is it my error anywhere?

double r = 0, vel = 0;
 int paramindex_begin, paramindex_end;
 string substring;
 for(paramindex_begin = command.size(); settings_string[paramindex_begin-1] != 'r'; paramindex_begin++);
 for(paramindex_end = paramindex_begin; paramindex_end < settings_string.size() && settings_string[paramindex_end] != ' ' && settings_string[paramindex_end] != '\n'; paramindex_end++);
 substring = settings_string.substr(paramindex_begin, paramindex_end-paramindex_begin);
 strcpy(settings_char, substring.c_str());
 r = atof(settings_char);


after this I stop by breakpoint and see:
substring = "380"
settings_char = 0xFF
r = 0

Thanks.

Parents Reply Children