0
How can we print a sentence without using the predefined printf statement in C?
printf statement is predefined in stdio.h header file and it is directly used from there but what if I want to print a statement using a user-defined function[viz view(); ].
5 Answers
+ 4
You can use this:
#include <stdio.h>
int main() {
char string[] = "testing...\n";
char *ptr = string;
while (*ptr)
putchar(*ptr++);
return 0;
}
It still uses a library function like printf, but is significantly easier than writing your own.
+ 2
... or using system("echo hello") đđđ
+ 2
Writing your own requires detailed knowledge of the operating system. They usually provide calls you can make to access the hardware devices or higher level concepts built on those devices. You would use that like the standard library does to replace it. There is open source code you can explore for the standard libraries written in C just a web search away. If you consider going into embedded software, you should definitely read that code.
+ 1
Nice one KrOW đ
đ
0
Martin Taylor what you mean by own routine and how it's written ?