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(); ].

14th Jun 2020, 2:16 AM
Krishna Kumar
Krishna Kumar - avatar
6 Réponses
+ 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.
15th Jun 2020, 3:40 AM
John Wells
John Wells - avatar
+ 2
... or using system("echo hello") 😂😂😂
14th Jun 2020, 9:34 AM
KrOW
KrOW - avatar
+ 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.
15th Jun 2020, 3:55 AM
John Wells
John Wells - avatar
+ 1
Nice one KrOW 😅😅
14th Jun 2020, 7:29 PM
Anthony Maina
Anthony Maina - avatar
0
Martin Taylor what you mean by own routine and how it's written ?
15th Jun 2020, 12:47 AM
Krishna Kumar
Krishna Kumar - avatar