what are the STDOUT, STDERR,STDUPDATE streams?

A

Abhishek

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
 
C

CBFalconer

Abhishek said:
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/>
 
P

pete

Abhishek said:
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 */
 

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

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top