By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,434 Members | 1,878 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,434 IT Pros & Developers. It's quick & easy.

reading from long string

P: n/a
Hi, ALL:

My question is I need read from a long string step by step, say first
read length 10 byes of string, process them, then read next 10 bytes of
that string.

Like the file operation fread. there is a pointer forwarding whenever I
read chunk from the file. Is any string read function provide such
kind of mechanism to record current pointer position of string?

Thanks for any comments .

bin YE

Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

yezi wrote:
Hi, ALL:

My question is I need read from a long string step by step, say first
read length 10 byes of string, process them, then read next 10 bytes of
that string.

Like the file operation fread. there is a pointer forwarding whenever I
read chunk from the file. Is any string read function provide such
kind of mechanism to record current pointer position of string?

Thanks for any comments .

bin YE


Why not operate the pointer by yourself?e.g. doing p+=10 every step
will record the current position in p,i think.

Nov 15 '05 #2

P: n/a
"yezi" <ye*****@hotmail.com> writes:
My question is I need read from a long string step by step, say first
read length 10 byes of string, process them, then read next 10 bytes of
that string.

Like the file operation fread. there is a pointer forwarding whenever I
read chunk from the file. Is any string read function provide such
kind of mechanism to record current pointer position of string?


No, there's no standard function to do this -- but you don't need one.
All you need to do is keep track of where you are in the string,
either with an integer index or with a pointer.

For example, given:

const char *s = "hello, world";

s is a pointer to a string whose value is "hello, world", and s+7 is a
pointer to a string whose value is "world".

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.