当前位置:网站首页>[C语言] sscanf如何实现sscanf_s?
[C语言] sscanf如何实现sscanf_s?
2022-08-11 07:39:00 【jianqiang.xue】
在MCU中并不支持sscanf_s,所以我们只能通过sscanf实现。
char user[33] = {
0};
char pass[33] = {
0};
sscanf_s(buf, "%s %s", user, pass);
// 用 sscanf实现
sscanf(buf, "%32[^ ] %32[^ ]", user, pass);

C 库函数 int sscanf(const char *str, const char *format, …) 从字符串读取格式化输入。
声明
下面是 sscanf() 函数的声明。
int sscanf(const char *str, const char format, …)
参数
str – 这是 C 字符串,是函数检索数据的源。
format – 这是 C 字符串,包含了以下各项中的一个或多个:空格字符、非空格字符 和 format 说明符。
format 说明符形式为 [=%[][width][modifiers]type=],具体讲解如下:
参数 描述
- 这是一个可选的星号,表示数据是从流 stream 中读取的,但是可以被忽视,即它不存储在对应的参数中。
width 这指定了在当前读取操作中读取的最大字符数。
modifiers 为对应的附加参数所指向的数据指定一个不同于整型(针对 d、i 和 n)、无符号整型(针对 o、u 和 x)或浮点型(针对 e、f 和 g)的大小: h :短整型(针对 d、i 和 n),或无符号短整型(针对 o、u 和 x) l :长整型(针对 d、i 和 n),或无符号长整型(针对 o、u 和 x),或双精度型(针对 e、f 和 g) L :长双精度型(针对 e、f 和 g)
type 一个字符,指定了要被读取的数据类型以及数据读取方式。具体参见下一个表格。
边栏推荐
- Redis source code-String: Redis String command, Redis String storage principle, three encoding types of Redis string, Redis String SDS source code analysis, Redis String application scenarios
- go 操作MySQL之mysql包
- 零基础SQL教程: 基础查询 05
- Pico neo3在Unity中的交互操作
- tf.reduce_mean()与tf.reduce_sum()
- FPGA 20个例程篇:11.USB2.0接收并回复CRC16位校验
- TF中的One-hot
- 通过记账,了解当月收支情况
- TF中的条件语句;where()
- 经典论文-MobileNet V1论文及实践
猜你喜欢

Pico neo3在Unity中的交互操作

The softmax function is used in TF;
![[Recommender System]: Overview of Collaborative Filtering and Content-Based Filtering](/img/bc/fd2b8282269f460f4be2da78b84c22.png)
[Recommender System]: Overview of Collaborative Filtering and Content-Based Filtering

1003 I want to pass (20 points)

1061 True or False (15 points)
1.1-Regression

tf.cast(),reduce_min(),reduce_max()

Tensorflow中使用tf.argmax返回张量沿指定维度最大值的索引
2.1-梯度下降

1081 Check Password (15 points)
随机推荐
go sqlx 包
迷你图书馆系统(对象+数组)
Pico neo3在Unity中的交互操作
1002 写出这个数 (20 分)
tf.cast(),reduce_min(),reduce_max()
The softmax function is used in TF;
项目1-PM2.5预测
There may be fields that cannot be serialized in the abnormal object of cdc and sqlserver. Is there anyone who can understand it? Help me to answer
1056 Sum of Combinations (15 points)
FPGA 20个例程篇:11.USB2.0接收并回复CRC16位校验
Square, multi-power, square root calculation in Tf
go-grpc TSL认证 解决 transport: authentication handshake failed: x509 certificate relies on ... ...
4.1-支持向量机
leetcode: 69. Square root of x
1106 2019 Sequence (15 points)
JRS303-Data Verification
3.2 - classification - Logistic regression
关于Android Service服务的面试题
Four operations in TF
oracle19c does not support real-time synchronization parameters, do you guys have any good solutions?