we have a default in build function (printf()) to display something on screen, is there any other way of printing the same thing ? say I have to display hello string on the screen and that too without using printf() function.
Asked
Active
Viewed 1,467 times
1
-
2Use `puts` or `putchar` :) – haccks Apr 10 '16 at 08:19
-
1Why is printf not allowed? What exactly are your requirements? Are any stdio functions allowed? – Martin R Apr 10 '16 at 08:36
-
duplication - http://stackoverflow.com/questions/16450587/is-it-possible-write-to-console-without-stdlibs-c-c – dear_tzvi Apr 10 '16 at 08:46
-
what my concern is without using any inbuilt function how can I print something on the screen. one of my friends suggested using a far pointer and point it to the video graphic memory and whatever is written there gets displayed on the screen. here is the sample code ************************************* #include
char far * video_mem=MK_FP(0xb800,0); void print_at(int x,int y,char color,const char * msg) { char far * ptr=video_mem+(80*y+x)*2; while (*msg) { *ptr++=*msg++; *ptr++=color; } } int main() { print_at(20,20,0x7,"Hello, world"); return 0; } – Yaseen Majeed Apr 12 '17 at 12:54
1 Answers
2
If your don't want to use printf()
there are always other options like putchar(), puts()
etc. But still if you don't want to use any one of them then use
system("echo Hello World!");
It will give you the output Hello World!

Shubham Khatri
- 270,417
- 55
- 406
- 400
-
this is what i was asking about #include
char far * video_mem=MK_FP(0xb800,0); void print_at(int x,int y,char color,const char * msg) { char far * ptr=video_mem+(80*y+x)*2; while (*msg) { *ptr++=*msg++; *ptr++=color; } } int main() { print_at(20,20,0x7,"Hello, world"); return 0; } – Yaseen Majeed Apr 12 '17 at 12:55