sscanf function reference (using of %*)

1. 函数定义

int sscanf ( const char * str, const char * format, ...);

有一种用法:
char*  reply = "String Ingnored 10";
int number;
sscanf(replay,"%*s %*s %d", &number);
 
代码中的 %*s 表明忽略一个字符串, 其中*的定义如下
  
  
  
  
* An optional starting asterisk indicates that the data is to be retrieved from the str string but ignored, i.e. it is not stored in the corresponding argument.
同理也可以将数字忽略
char* reply = "number ingored 10";
char str1[256];
char str2[256];
sscanf(reply,"%s %s %*d",str1, str2);
  

你可能感兴趣的:(sscanf function reference (using of %*))