472,128 Members | 1,654 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,128 software developers and data experts.

what are the STDOUT, STDERR,STDUPDATE streams?

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
2 2689
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
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.

Similar topics

140 posts views Thread by Oliver Brausch | last post: by
momotaro
2 posts views Thread by momotaro | last post: by
8 posts views Thread by subramanian100in | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.