在屏幕上打印的任何其他方式而不是 C 中的 printf() 和 fprintf() ? [英] Any other way to print on the screen instead of printf() and fprintf() in C?

查看:56
本文介绍了在屏幕上打印的任何其他方式而不是 C 中的 printf() 和 fprintf() ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 CentOS 5.5 中使用 gcc 编程,大部分时间我使用 printf()fprintf() 来打印终端,但在某些网站上,我看到有些人使用 write().我想知道是否有其他方法可以在终端上打印.

I'm programming with gcc in CentOS 5.5 and the most of time I use printf() and fprintf() to print on terminal, but in some websites I've seen that some people use write(). I want to know if there's other ways to print on terminal.

谢谢.

推荐答案

这些功能之间存在一些主要差异.

There are some major differences between these functions.

  1. 标准库提供了一些输出到stdout的函数:printfputsputchar
  2. 还有一些输出到流的函数,你可以指定流到stdout:fprintf, fputs, fwrite
  3. 但是write 不同,它是一个底层的I/O 函数.这标准库不提供任何低级 I/O 函数.为了例如,POSIX 提供了可以输出到文件的 write描述符.
  1. The standard library provides some functions to output to stdout: printf, puts, putchar etc.
  2. And some functions to output to a stream, you can specify the stream to stdout: fprintf, fputs, fwrite, etc.
  3. But write is different, it's a low-level I/O function. The standard library doesn't provide any low-level I/O functions. For example, POSIX provides write that can output to a file descriptor.

Google 了解如何使用它们.

Google for how to use each one of them.

这篇关于在屏幕上打印的任何其他方式而不是 C 中的 printf() 和 fprintf() ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆