sscanf 怎么解析 "a1do&123456" 到 buf1=a1do 和 buf2=123456被弄晕了, 我怎么写只能得到前面一节.谢谢大家!
解决方案 »
- 父窗口里的wm_drawitem是不是不能够用fillrect?
- 简单创建的一个窗口,查错?
- 静态链接到MFC的规则DLL为什么不需要进行模块状态转换,而动态的为什么需要
- 显示删除的进度.
- 程序在开发环境下可以,在实际环境运行2、3天后出错(Visual C++ Runtime Library)
- 请问vc里面怎么关掉进入汇编调试模式!!急!!!
- 怎样得到和某种文件关联的图标的句柄?
- Static Text和Picture控件如何接受Click事件?在向导中可以加入,但运行时无反应
- 中断问题
- 现有一个很有趣的问题寻求计算机解法 100分奖励
- 我来问个问题吧 都来看看 发消息的问题 其实挺简单的 就是搞不定~ - -
- 关闭MessageBox弹出的消息框
我是想学学sscanf ,我之前是用的 Find 类似你的方法.
sscanf不是用在这种场合
char temp[20];
int a;
_stscanf(_T("a1do&123456"), _T("%[^&]&%d"), temp, &a);
CString str;
str.Format(_T("%s %d"), temp, a);
MessageBox(str);
TCHAR temp[20];
TCHAR temp1[20];
_stscanf(_T("a1do&123456"), _T("%[^&]&%s"), temp, temp1);
CString str;
str.Format(_T("%s %s"), temp, temp1);
MessageBox(str);
晕, 好像 temp1 2必须是TCHAR, 不能使CString 哦? 难怪我试了好久也不行
Specifier Meaning
%dAn integer in normal decimal (that is, base-10) notation.%oAn integer in octal (base-8) notation.%xAn integer in hexadecimal (base-16) notation.%DAn integer in decimal, or (if it starts with 0) octal, or (if it starts with 0x) hexadecimal notation. Hence, sscanf("12", "%D", i), sscanf("014", "%D", i) and sscanf("0xC", "%D", i) all yield the value 12 in i.%fA floating-point number.%cThe character code of a single character.%sA string. If %s is followed by %d, %s will read any non-numerical characters. If followed by %[], %s will read any characters not present in the set in the %[]. If followed by normal text, %s will match all characters up to, but not including, the first occurrence of that text.%NsAs above, but a string of exactly N characters%[characters]A string containing any of the characters in the list characters.A minus sign can be used to give a range of values, so e. g. %[a-d] means a string consisting of any of the characters a, b and c.A ^ sign means "not", so e. g. %[^abc] means any character except a, b and c.They can be combined, so %[a-cf] means a, b, c, and f.