Sponsored Content
Full Discussion: stdio.h vs unistd.h I/O
Top Forums Programming stdio.h vs unistd.h I/O Post 302453011 by frank_rizzo on Monday 13th of September 2010 08:34:19 PM
Old 09-13-2010
stdio.h and unistd.h are header files, not libraries. stdio.h is the header for stream/buffered I/O(like printf()). unistd.h is the header for the POSIX API(like read()). You probably see the use of low level functions like read() because the examples are working directly with file descriptors - ie: sockets. stream I/O uses file pointers. The choice to use buffered/non-buffered I/O depends on what the application is doing.
 

6 More Discussions You Might Find Interesting

1. Programming

Atomic Read and Write with stdio

hi guys. can we use fread and fwrite with pipes to write data more than PIPE_BUF atomically since they lock FILE object until I/O operation finish? (1 Reply)
Discussion started by: majid.merkava
1 Replies

2. Programming

FILE structure - stdio.h

Hi All, I am new to linux and Programming. Inside the file stdio.h, there is a description about FILE structure. Which has many internal data members like _p, _r, _flags etc. I have written a sample code to find out the contents of the FILE structure. It opens a sample file ( FILE *fp ),... (5 Replies)
Discussion started by: nikunjbadjatya
5 Replies

3. Programming

stdio.h not found on Solaris 11

Hi friends, I hope u r doing well. I have just installed Solaris 11, and it seems that solaris 11 doesn't come with all the packages, one has to do everything manually. I download gcc from sunfreeware.com and installed it. After setting up the path variable, I tried to compile the hello world... (4 Replies)
Discussion started by: gabam
4 Replies

4. Solaris

fatal error: stdio.h: No such file or directory

Trying to compile a C program recievin this hello.c:1:19: fatal error: stdio.h: No such file or directory gcc is installed on the system. echo $PATH /usr/bin:/usr/sbin:/usr/gcc/4.5/include/c++/4.5.2/tr1 root@Sol11swtb01:/media/NO NAME/Programming/C/Testing# cd... (2 Replies)
Discussion started by: Fingerz
2 Replies

5. Programming

Ignoring the stdio.h file in a C file

I am facing a problem in the below given code. int main() { printf("\nHello Geeks\n\n") ; return 0 ; } In the above mentioned code i left including "#include ". And if i compile and execute this piece of code, the output is printed as expected. But "#include " being the most important... (7 Replies)
Discussion started by: Raj 89
7 Replies

6. Programming

C++ : is what the meaning of #include<stdio.h>?

Hello Guys, I'm new in programing line & just started from C++ programs but i don't know the meaning of #include<stdio.h> file....Guys tell me what's the working of this file in C++ program?? I'm confused... Title changed: Please use a descriptive subject text, and not C++?? (3 Replies)
Discussion started by: ggiwebsinfo
3 Replies
STDIN(P)						     POSIX Programmer's Manual							  STDIN(P)

NAME
stderr, stdin, stdout - standard I/O streams SYNOPSIS
#include <stdio.h> extern FILE *stderr, *stdin, *stdout; DESCRIPTION
A file with associated buffering is called a stream and is declared to be a pointer to a defined type FILE. The fopen() function shall cre- ate certain descriptive data for a stream and return a pointer to designate the stream in all further transactions. Normally, there are three open streams with constant pointers declared in the <stdio.h> header and associated with the standard open files. At program start-up, three streams shall be predefined and need not be opened explicitly: standard input (for reading conventional input), standard output (for writing conventional output), and standard error (for writing diagnostic output). When opened, the standard error stream is not fully buffered; the standard input and standard output streams are fully buffered if and only if the stream can be determined not to refer to an interactive device. The following symbolic values in <unistd.h> define the file descriptors that shall be associated with the C-language stdin, stdout, and stderr when the application is started: STDIN_FILENO Standard input value, stdin. Its value is 0. STDOUT_FILENO Standard output value, stdout. Its value is 1. STDERR_FILENO Standard error value, stderr. Its value is 2. The stderr stream is expected to be open for reading and writing. RETURN VALUE
None. ERRORS
No errors are defined. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
None. RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
fclose() , feof() , ferror() , fileno() , fopen() , fread() , fseek() , getc() , gets() , popen() , printf() , putc() , puts() , read() , scanf() , setbuf() , setvbuf() , tmpfile() , ungetc() , vprintf() , the Base Definitions volume of IEEE Std 1003.1-2001, <stdio.h>, <unistd.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 STDIN(P)
All times are GMT -4. The time now is 04:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy