You are here:

C/output for a c program

Advertisement


Question
thanks
but write() is used to write strings in a file.
how can i use it to print integer numbers in the computer screen(it has to be faster than printf()function).?
again similarly if there is faster process to take input of integer numbers than using scanf() function.?



-------------------------
Followup To
Question -
can u give another faster techniques to give output of integers instead of using printf() function?
Answer -
Use write() system call.

Answer
printf() is just a wrapper around the write() system call.
If you are on Linux or Unix, then you can get the man page of write() on your terminal.

If you are on windows, I don't know the system call used there.

Actually, write() can be used to write to any device, including your desktop terminal. Also, it can be used to write data to a file.
Where it writes, depends on the file descriptor that you give.
If you give STDOUT, then it will write to terminal.

All these make use of the underlying device driver for all their work.
So, if you want to be faster than the current implementation, then you will have to write your own device driver and use it.

Hope this clears.

-Narendra

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Narendra

Expertise

I can answer questions in C related to programming, data structures, pointers and file manipulation. I use Solaris for doing C code and if you have questions related to C programming on Solaris, I will be able to help better.

Experience

6.5

Organizations belong to
Sun Microsystems

Awards and Honors
Brain Bench Certified Expert C programmer.
Advanced System Software Certified

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