printf() implementation using write() ?
I need to write a printf() implementation using write. Variable argument list, the whole deal. Does anyone know a simple method to achieve this?
|
The simplest answer is to review the printf implementation in glibc source.
If this is for fun, great. If not why are you doing this? printf is a large chunk of code. |
Try this one
#include<unistd.h> int main() { int d=10; char str[100]; sprintf(str,"hai d= %d",d); write(1,str,sizeof(str)); return 0; } Is this You want? |
> Does anyone know a simple method to achieve this?
i dont understand the question. if you have to write your own implementation of it, then write your own implementation of it. you will have to study how to use var_arg lists and figure out how to parse the specifiers out of the format string, then sit down and write it. if it does not have to be your own implementation of it then just look at the printf source and copy it. |
All times are GMT -5. The time now is 10:24 AM. |