473,387 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 2798
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hans Deragon | last post by:
Greetings. I am performing: commands.getstatusoutput("rsync <params>"); rsync takes a long time and prints out a steady stream of lines showing which file it is currently working on.
4
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
140
by: Oliver Brausch | last post by:
Hello, have you ever heard about this MS-visual c compiler bug? look at the small prog: static int x=0; int bit32() { return ++x; }
23
by: herrcho | last post by:
What's the difference between STDIN and Keyboard buffer ? when i get char through scanf, i type in some characters and press enter, then, where do the characters go ? to STDIN or Keyboard...
37
by: nobody | last post by:
I am writing a framework that other developers will write plug-ins for. I would like for one of the features of the framework to be to intercept all text written to stdout/stderr and prepend...
2
by: Murali | last post by:
Hi Python programmers, I need to be able to read the stdout and stderr streams of an external program that I launch from my python script. os.system( 'my_prog' + '>& err.log' ) and was planning...
2
momotaro
by: momotaro | last post by:
Hello! am wondring if stdin, stdout and stderr are of any help since we can do the same thing using 'printf' for example: fprintf(stdout, "%s", message); is exactely the same as: ...
7
by: Cell | last post by:
when both are connected to screen and the anything written to these two constant file pointers will go onto the screen ?
8
by: subramanian100in | last post by:
The file stdio.h just contains extern FILE *stdin; extern FILE *stdout; extern FILE *stderr; When are the standard streams stdin, stdout, stderr initialiazed ? How are they initialiazed ? ...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
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
0
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...
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.