Is there a way to have a C
source file print to the screen without including <stdio.h>
?
Here's my situation: I was asked to programatically handle 1000 C
source files that will each implements several numerical functions in C
(these functions are supposed to work on data that is in memory, eithout any I/O). The origin of these source files in unclear, and hence, I'd like to make sure there will be no harm to my machine when I compile & run these source files.
Is there a way to find out if a C
source file is potentially harmful? I thought of asking the developers to avoid any #include
statements whatsoever, but I do need just printf
-- as I'd like them to include an output of their calculations within main()
.
Any ideas?
8) The statement used for printing \n on the screen is:printf("n\");
How do you print your name in C language without using any printing function like printf and all? int main() { write(1, "Hello World", strlen("Hello World")); return 0; } This could be one way of printing without using printf, sprintf, and all related functions.
The most basic printing functions would be puts and putchar which print a string and char respectively. f is for formatted. printf (unlike puts or putchar ) prints formatted output, hence printf. For example it can print an int in hexadecimal, or a float rounded to three decimal places, or a string left padded.
Sure, add the prototype for printf
at the top of your source file, as long as you're linking to the CRT libraries you can use the function without including stdio.h
printf
prototype
int printf ( const char * format, ... );
There are, though they are probably a bit larger than the scope of the format of SO. In essence you leverage assembler calls in C. The blog KSplice touches on the subject ( with code and examples ) here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With