Is it possible to write a "hello world" program in C without the use of the printf function? (while still keeping the program relatively at a few lines)
This should work:
int main (void)
{
puts("Hello, World!");
return 0;
}
Why don't you want to use printf
? I can't think of any reason not to.
Well, if we're going to include silly examples (yes, I'm looking at you, technosauraus), I'd go with:
#include <stdio.h>
void makeItSo (char *str) {
if (*str == '\0') return;
makeItSo (str + 1);
putchar (*str);
}
int main (void) {
makeItSo ("\ndlrow olleH");
return 0;
}
Just don't do this for really long strings or you'll find out what Stack Overflow really means :-)
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