How will you print any character, string or value of a variable without library functions in C?

前端 未结 4 763
攒了一身酷
攒了一身酷 2020-12-29 15:28

If for example I should not use standard library functions like printf(), putchar() then how can I print a character to the screen?

Is there

4条回答
  •  孤城傲影
    2020-12-29 16:09

    In standard C, you can't. The only I/O defined in C is through the C standard library functions.

    On a given platform, there may be ways to do it:

    • Make kernel calls directly. You will probably need to write some inline assembly to do this. You could make litb's write call directly, without using your C library. Grab the source of your C library to see how it's done.
    • Write directly to the frame buffer. Multi-user OS's often disallow this (at least without making any library/kernel calls).

    Unless you're writing your own C library, I'm not sure why you'd want to do this.

提交回复
热议问题