You are here:

C/read fuction in c

Advertisement


Question
hello sir
i m paritosh, and i want to know that what is the meaning of the read function with argument file descriptor as 0
i.e.
read(0,buffer,sizeof(buffer))

thank you

Answer
Hello Paritosh.

When a program starts, there are three file descriptors open. The stdin file descriptor reads from the keyboard. The stdout and stderr print to the screen. Usually, stdin in given the value of 0, so when the program does read(0...), it is doing a read from stdin. It would be better style, and more correct to use read(stdin, ...), instead of read(0...)

Best regards
Zlatko

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Zlatko

Expertise

No longer taking questions.

Experience

No longer taking questions.

Education/Credentials
No longer taking questions.

©2012 About.com, a part of The New York Times Company. All rights reserved.