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

what are the STDOUT, STDERR,STDUPDATE streams?

P: n/a
what are the STDUPDATE, STDERR, STDOUT and STDIN streams and how does
one access these streams in C language. I am aware of the function
fprintf(FILE *fp, char * format, char *s) which puts the string into
the corresponding streams. But can you please tellme where does the
content go exactly when we put it into the above streams. In which
cases can we see the outpt and in which cases cant we see and why so?
It would be great if you can give me an example.
Bye

Feb 21 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Abhishek wrote:

what are the STDUPDATE,
I don't know.
STDERR, STDOUT and STDIN streams
Standard error stream, standard output stream,
and standard input stream.
and how does
one access these streams in C language.
They are opened automatically when a hosted C program executes.
The stdout, stdin, and stderr macros, are (FILE *) values.
They are used similarly to the way
that the return value of fopen() is used,
except they get closed automatically at the end of the program
so fclose(), doesn't apply to them.
I am aware of the function fprintf(FILE *fp, char * format, char *s)
#include <stdio.h>
int fprintf(FILE * restrict stream,
const char * restrict format, ...);
which puts the string into
the corresponding streams. But can you please tellme where does the
content go exactly when we put it into the above streams.
Each stream is associated with a file or device.
On my machine, the standard input stream
is associated with my keyboard.
The standard output and standard error streams are associated
with my monitor.
In which
cases can we see the outpt and in which cases cant we see and why so?
It would be great if you can give me an example.


/* BEGIN new.c */

#include <stdio.h>

int main(void)
{
fputs("\nIf you can read this,\n"
"then you're looking at the device "
"which is associated with\n"
"the standard output stream\n", stdout);

fputs("\nIf you can read this,\n"
"then you're looking at the device "
"which is associated with\n"
"the standard error stream\n", stderr);

puts("\n\nEnter a string for the standard input stream.");
fscanf(stdin, "%*[^\n]");
if (!feof(stdin)) {
getc(stdin);
}

puts("\nOK, that's all there is.");

return 0;
}

/* END new.c */

--
pete
Feb 21 '06 #2

P: n/a
Abhishek wrote:

what are the STDUPDATE, STDERR, STDOUT and STDIN streams and how does
one access these streams in C language. I am aware of the function
fprintf(FILE *fp, char * format, char *s) which puts the string into
the corresponding streams. But can you please tellme where does the
content go exactly when we put it into the above streams. In which
cases can we see the outpt and in which cases cant we see and why so?
It would be great if you can give me an example.


They don't exist. What does exist are stdout and stderr for
output, and stdin for input. To see where the streams are
delivered, see your systems documentation. The most common thing
is the associated terminal.

You access them by reading or writing to them. For example:

intvalue = getc(stdin);
or
intvalue = getchar(); /* assumes stdin */

Please do not fail to read the following URLs and advice before
posting again.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
Feb 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.