0

Hi there,

I'm working with a file. I want to write a code that returns a particular string located somewhere in the file. I have the starting position of the desired string and it's length so I thought that i can use substr(starting position, length of the string) but it doesn't work anybody has any idea to help me.

I really appreciate it,

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by YasaminKh
0

you have the starting position and the length of the string, so just start reading character by character from the starting position length number of times.

0

I think i could have done that if i had a string, by writing something like this:

string t = "";
for(int i=start;i<start+length;i++){
            t+=sentence[i]; }

But in the Code that I'm writing, the larger string that i called it sentence in above sample, hasn't been specified as a string.

I might not be on a right track. I'm new to C++ (and programming in general). SO could you please explain it to me how can i read it character by character as you said.

Edited by Reverend Jim: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.