首页 > 其他分享 >sscanf

sscanf

时间:2023-03-04 20:23:20浏览次数:25  
标签:sscanf int scanf char 字符串 const

(一)说明

sscanf的作用:从一个字符串中读进于指定格式相符的数据。利用它可以从字符串中取出整数、浮点数和字符串。

sscanf和scanf的区别:scanf是以键盘作为输入源,sscanf是以字符串作为输入源。

(二)函数原型

#include <stdio.h>

int sscanf(
const char *str, //待解析的字符串;
const char *format, ...//字符串格式描述,其后是一序列数目不定的指针参数,存储解析后的数据.
);

(三)使用样例

 //格式化日期
    int t[3] = { 0 };
    sscanf_s(m_strData.GetBuffer(), "%d-%d-%d", &t[0], &t[1], &t[2]);

 

标签:sscanf,int,scanf,char,字符串,const
From: https://www.cnblogs.com/imreW/p/17179002.html

相关文章

  • scanf/sscanf 的使用
    普通使用scanf(format,p1,p2,p3,...)sscanf(str,format,p1,p2,p3,...)意为以format字符串匹配stdin/str,将结果传到p1,p2,p3,...所代表的地址里2.format使用......
  • Poj 2503 map sscanf
    Poj2503mapsscanf题意字符串的映射,但它输入的方式很怪。首先每行输入两个单词,中间隔一个空格,到输入空行为止。然后每行输入一个单词,如果能存在映射的单词就输出对......
  • undefined reference to `__isoc99_sscanf'
    参考文章:​​http://www.linuxquestions.org/questions/programming-9/undefined-reference-to-%60__isoc99_sscanf%27-873058/​​原文关键内容:Youhaveglibcversionpri......
  • sscanf 和 sprintf 使用
    sscanf的使用intsscanf(constchar*str,constchar*format,......);#include<stdio.h>intmain1(){charstr[100];sscanf("12345","%4s",str);......