Thursday, July 9, 2009

U can write anything without using printf statement in c. but how?

putchar, or write to the terminal.

U can write anything without using printf statement in c. but how?
putchar and its related commands
Reply:printf is really just a wrapper around the write() function.





use write and the stdout file descriptor with a pointer to the memory of your output statement and the amount of data to write.





For example.





char *ptr = "Hello World.\n";





write( 1, ptr, 13 );





to achieve the same as





fprintf( stdout, "%s", ptr );


No comments:

Post a Comment