Delimited by a chr(255)

J

James Prato

In C, how do you read data fields from a file that are separated/delimited
by a chr(255)?

For example, Field1chr(255)Field2chr(255), etc where Fieldx could be NULL.
 
B

Ben Pfaff

James Prato said:
In C, how do you read data fields from a file that are separated/delimited
by a chr(255)?

You could read characters with fgetc() until you encounter a
character with value 255. (In C, we don't use your "chr"
notation; perhaps you are more familiar with Pascal or Perl than
with C.)

Have you tried writing code to do this? What difficulties did
you encounter? It is quite straightforward.
 
K

kondal

James said:
In C, how do you read data fields from a file that are separated/delimited
by a chr(255)?

For example, Field1chr(255)Field2chr(255), etc where Fieldx could be NULL.

The question is unclear to me. Did you meant Field1 and Field2 are
character buffers of size of 255 or you meant the strings are seperated
by ascii character 255?

-kondal
 
R

Richard Heathfield

kondal said:
The question is unclear to me. Did you meant Field1 and Field2 are
character buffers of size of 255 or you meant the strings are seperated
by ascii character 255?

Neither. He didn't mention ASCII, and he didn't mention buffer sizes.

He is trying to tokenise on a given character, that's all. The solution is a
simple getc loop.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top