Essential Input and Output

本文介绍了如何使用C++中的safe函数scanf_s进行键盘数据输入,以及printf_s用于屏幕输出的格式化方法,特别强调了printf_s中%n输出规范的限制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

How to read data from the keyboard?
How to format data for output on the screen?
How to deal with character output?

一、Input from the Keyboard

the scanf_s() function that is the safe version of scanf()

int scanf_s(const char * restrict format, ... );

 Examples of Options in Conversion Specifications

 

二、Output to the Screen

 The primary function for formatted output to the stdout stream is printf(),

The stdio.h header may also declare the optional printf_s() function, which is a safe version
of printf().

The primary difference between printf() and printf_s() is that printf_s() does not permit the %n output specification to be included in the format string. This is because the %n output specification writes data to memory, and this makes it unsafe.

int printf_s(char *format, ...);

 

Effects of the Optional Flag Characters in an Output Specification

Size Flag Characters in an Output Specification

Conversion Characters in an Output Specification

Escape Sequences for Whitespace Characters

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

issta

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值