![]() |
trouble reading string into array
so i've got this string called code, of type std::string, which has this inside it
Quote:
:
int last_flushed = 0;it just prints out this: Quote:
|
You are using a lot of things there which you neither show nor define nor explain. Crystal balls are nice, but we don't all have one. Would you care to think about your post, think about your problem, think about your audience, and elucidate?
|
I have no idea what you're trying to do here. Can you post some more code?
|
I tried reading through that code and i hit dead ends that could be vital to explaining whats wrong.
For example code.size() in the for loop. |
I'm sorry, I forgot to post string_copy()'s definition:
:
string string_copy(string source, int startpos, int length)the idea with that function is to return a 'length' substring of 'source', starting at 'startpos'. the idea of all this was to take a string containing several lines, each seperated by a newline (\n) and put each line into a seperate element of the array statements. the variable last_flushed is so it puts a substring of 'code', between last_flushed (the end of the last string put into the array) and i (the position of the next \n) and not everything from the beginning to whatever newline it encounters. @coldDeath: size() is a member of std::string. code.size() returns the length of the string 'code'. |
Ty, I couldn't see any variables called code, so i got a little confused.
|
Instead of string_copy, why not just do this?
:
std::string myNewString = myOldString.substr(offset, length); |
coldDeath: np
Ooble: thanks, i got it working. yay. |
| All times are GMT -5. The time now is 8:55 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC