Can someone please show me an example of how fpurge might be used? Does
anyone use this function anymore and is it anything like fflush() ?
Bill 12 17761
Bill Cunningham wrote:
Can someone please show me an example of how fpurge might be used? Does
anyone use this function anymore and is it anything like fflush() ?
fpurge is not in the standard C library. It is nonstandard and not
portable. It is a BSD function. The similar _fpurge is a Solaris
function, available in some versions of glibc. Any questions about them
belong, therefore, in a forum for BSD or Solaris or GNU.
"Bill Cunningham" <no****@nspam.invalidwrites:
Can someone please show me an example of how fpurge might be used? Does
anyone use this function anymore and is it anything like fflush() ?
No. fpurge is non-standard (it's not even POSIX) and extremely
non-portable; even on systems that support it, it's not recommended.
Did you read the man page before posting? If so, didn't it tell you
this? If not, why?
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
On 13 Oct 2008 at 1:51, Bill Cunningham wrote:
Can someone please show me an example of how fpurge might be used?
Does anyone use this function anymore and is it anything like
fflush() ?
Here's the description from the manpage:
<quote>
The function fpurge() clears the buffers of the given stream. For
output streams this discards any unwritten output. For input streams
this discards any input read from the underlying object but not yet
obtained via getc(3); this includes any text pushed back via
ungetc(3).
</quote>
IME, use of this function is rare. Here's an example of a function where
it comes in useful for dealing with line-buffered input from a terminal:
int getyesno(const char *prompt)
{
int ch;
for (;;) {
fpurge(stdin);
printf("%s?\n", prompt);
ch = toupper(getchar());
switch (ch) {
case 'N':
case EOF:
return 0;
case 'Y':
return 1;
default:
printf("'%c' is not a valid answer: enter 'Y' or 'N'\n", ch);
continue;
}
}
}
In article <gc**********@registered.motzarella.org>,
Martin Ambuhl <ma*****@earthlink.netwrote his usual blather, so I've
edited it for content:
>Bill Cunningham wrote:
> Can someone please show me an example of how fpurge might be used? Does anyone use this function anymore and is it anything like fflush() ?
>Someone can, but I can't, because I am a clueless fool.
Hope that clarifies things.
"Martin Ambuhl" <ma*****@earthlink.netwrote in message
news:gc**********@registered.motzarella.org...
fpurge is not in the standard C library. It is nonstandard and not
portable. It is a BSD function. The similar _fpurge is a Solaris
function, available in some versions of glibc. Any questions about them
belong, therefore, in a forum for BSD or Solaris or GNU.
Oh I was looking online thought it was with the standard library Sorry.
I'll check where appropriate.
Bill
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
No. fpurge is non-standard (it's not even POSIX) and extremely
non-portable; even on systems that support it, it's not recommended.
Did you read the man page before posting? If so, didn't it tell you
this? If not, why?
Look at this Keith this is where I got this. They better correct their
info. And they show good examples at times. http://www.cppreference.com/wiki/c/io/start
"Bill Cunningham" <no****@nspam.invalidwrites:
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
>No. fpurge is non-standard (it's not even POSIX) and extremely non-portable; even on systems that support it, it's not recommended.
Did you read the man page before posting? If so, didn't it tell you this? If not, why?
Look at this Keith this is where I got this. They better correct their
info. And they show good examples at times.
http://www.cppreference.com/wiki/c/io/start
That web page is a wiki. I just deleted the reference to fpurge. I
also added a note to the fpurge page itself (which is no longer in the
index, but the page still exists).
The fact that I was able to do so, without even setting up an account,
suggests that it's not a reliable source of information. I could just
as easily have deleted correct information or added deliberate
misinformation.
I think I've mentioned K&R2 to you many many times.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
"Keith Thompson" <ks***@mib.orgwrote in message
news:ln************@nuthaus.mib.org...
That web page is a wiki. I just deleted the reference to fpurge. I
also added a note to the fpurge page itself (which is no longer in the
index, but the page still exists).
The fact that I was able to do so, without even setting up an account,
suggests that it's not a reliable source of information. I could just
as easily have deleted correct information or added deliberate
misinformation.
I think I've mentioned K&R2 to you many many times.
It's helpful at times. At times the depth of info blasts me.
Bill
"Bill Cunningham" <no****@nspam.invalidwrites:
"Keith Thompson" <ks***@mib.orgwrote:
>I think I've mentioned K&R2 to you many many times.
It's helpful at times. At times the depth of info blasts me.
Unlike many of the other sources of information you seem to be using,
K&R2 does _not_ contain [too much] stuff that's Just Wrong.
Bill, if you want to use a function, look it up in K&R2 first.
If it's not there, don't use it.
mlp
"Mark L Pappin" <ml*@acm.orgwrote in message
"Bill Cunningham" <no****@nspam.invalidwrites:
Bill, if you want to use a function, look it up in K&R2 first.
If it's not there, don't use it.
If it's not in K and R it isn't in the standard library. However that
doesn't mean you should never use non-standard functions. In fact, some
common tasks, such as listing the files in a directory, can't be done
without going outside the confines of the standard.
However if you use a non-standard fucntion, be aware that it won't be
portable to all systems. In fact between them Windows and Unix manage to
break most non-conservative programs.
--
Free games and programming goodies. http://www.personal.leeds.ac.uk/~bgy1mm
On 14 Oct 2008 at 19:08, Malcolm McLean wrote:
"Mark L Pappin" <ml*@acm.orgwrote in message
>Bill, if you want to use a function, look it up in K&R2 first. If it's not there, don't use it.
If it's not in K and R it isn't in the standard library.
This is not true. There are plenty of functions in the standard library
of the CURRENT standard that aren't mentioned in K&R. They may not be
Heathfield-approved since they're post-C90, but indisputably they're in
the standard library.
This K&R acid test is particularly amusing when you remember that
Section 8.3 of K&R2 is entitled "Open, creat, close, unlink". According
to the dogma of most of the regulars, these functions are "not C" and
"off-topic" for this group.
However that doesn't mean you should never use non-standard functions.
Absolutely right.
Malcolm McLean said:
>
"Mark L Pappin" <ml*@acm.orgwrote in message
>"Bill Cunningham" <no****@nspam.invalidwrites: Bill, if you want to use a function, look it up in K&R2 first. If it's not there, don't use it.
If it's not in K and R it isn't in the standard library.
Counter-example: strcoll (and it isn't the only one).
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jonathan Neill |
last post by:
I'm aware that there is no ANSI (or POSIX, or any standard, to my knowledge)
way of flushing stdin or any other application-level input buffer, but if
anyone knows a hack or a non-portable way to...
|
by: JG |
last post by:
Does anyone know a standard (or supported on Linux, Mac, Win32) way to
clear a read stream buffer (standard ANSI C file stream)?
I would even settle for a platform specific way of doing it.
...
|
by: Martin Jørgensen |
last post by:
Hi,
Consider:
------------
char stringinput
..bla. bla. bla.
do
{
|
by: robert maas, see http://tinyurl.com/uh3t |
last post by:
I'm working on examples of programming in several languages, all
(except PHP) running under CGI so that I can show both the source
files and the actually running of the examples online. The first...
|
by: Eoghan |
last post by:
Hi there! I have two simple questions about a program i'm doing:
1) if I write:
enum logic {VERO=1, FALSO=0};
logic trovato=VERO;
Is this correct according to the ANSI '89 standard?
2) I...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |