Re: another simple C question please...
Re: another simple C question please...
- Subject: Re: another simple C question please...
- From: "John Baker" <email@hidden>
- Date: Fri, 29 Aug 2003 09:49:19 -0500
I'm sorry... you are looking at C. peek() is in the C++ libraries...
Try this macro:
#define PEEK(FP) (c = getc (FP), ungetc (c, FP))
John Baker
----- Original Message -----
From: "David Thorp" <email@hidden>
To: <email@hidden>
Cc: "Joe Osborn" <email@hidden>
Sent: Friday, August 29, 2003 9:06 AM
Subject: another simple C question please...
>
Greetings...
>
>
I wonder if any of you could help me on this one please. Thanks again
>
to everyone for all the help in the past. This one's pretty simple I
>
think...
>
>
In short, is there any way, before reading in a character from a file
>
(using something like: ch = fgetc (theFile)), to instead find out what
>
the next character is, before actually reading it and moving the file
>
position indicator along one?
>
>
------------------
>
>
For a more lengthy explanation of what I'm trying to do:
>
>
I'm using functions like:
>
>
int NextCharsOfFileToInteger (FILE *theFile, char parser)
>
{
>
int result = 0;
>
char ch;
>
while ( (ch = fgetc (theFile)) != parser )
>
{
>
result = (result * 10) + (ch-'0');
>
}
>
return result;
>
}
>
>
and I'll of course pass a file pointer and a character to this function.
>
>
I wouldn't be surprised if there's a better way to do this particular
>
function, and if so I'm all ears, but my question above is still
>
relevant, because I have a few functions like this reading in
>
characters from the file up to a certain character and then doing one
>
thing or another with them.
>
>
The question is, I want to be sure before I get into this function that
>
the next character is NOT certain things. I don't want the function to
>
have to figure it out.
>
>
----------------
>
>
Can anyone help please?
>
>
Thanks in advance!
>
David.
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.