0
我有2个问题。字符数组到整数
在这里,在C++参考
#include <stdio.h>
int main()
{
char sentence []="Rudolph is 12 years old";
char str [20];
int i;
sscanf (sentence,"%s %*s %d",str,&i); <---
printf ("%s -> %d\n",str,i);
return 0;
}
问题1.到底是什么%* S在做什么?
我的程序我在建立一个哈希表。
它查询在
q- quit
i <int> - inserts integer //must be on same line
d <int> - deletes integer //must be on same line
etc....
For example:
in order to insert "35" I would have to type:
i 35
问题2.用户或者类型将在C++以来“Q”两者“Q”和“我35”参考工作具有与它没有整数?
char choice[10];
char option;
int i;
sscanf(choice, "%c %d", &option, &i);
将这工作如果 'Q' 被输入(没有整数附后)以及在 “i 35” 被输入(W /整数附后)?
我会编辑我的帖子,使其更清晰 – juice 2013-04-10 23:51:44
已更新的答案。 – 2013-04-11 00:01:27