I have a string like this :
char cstr[] = "i 176064 Patterson Denise 8.58 11 DEN 15788 ";
and i want to get only the fist word 'i' with sscanf
int main()
{ char cstr[] = "i 176064 Patterson Denise 8.58 11 DEN 15788 ";
char option[20];
sscanf(cstr, "%s",option);
}
what i have to do to ignore the rest of the string?
您无需执行任何操作,因为scanf
函数会自动忽略任何尾随字符。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.