【发布时间】:2013-04-10 23:43:34
【问题描述】:
我有 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' 和 'i 35' 因为 'q' 没有整数?
char choice[10];
char option;
int i;
sscanf(choice, "%c %d", &option, &i);
如果输入了“q”(未附加整数)以及输入“i 35”(附加整数),这是否有效?
【问题讨论】: