Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试(在 C 中)从具有如下行的文件中读取:
GFE_1 GFE_8 GFE_19
我想使用 fscanf 忽略字母和 _ 并将末尾的数字放入变量中。
显然我所拥有的是不正确的:
fscanf(f, "%d", number);
如果它们被空格分隔,我知道如何跳过它们,但在这种情况下我被卡住了。
像这样的东西怎么样
fscanf(f, " %*[^A-Z]_%d", &number);
或者如果主角总是相同的,它就像
fscanf(f, " GFE_%d", &number);
您可以使用此语句跳过阅读字母和_
int fscanf ( FILE * stream, const char * format, ... );