gpt4 book ai didi

c - 使 fscanf 忽略 int 前没有空格的字母

转载 作者:太空宇宙 更新时间:2023-11-04 06:34:40 25 4
gpt4 key购买 nike

我正在尝试(在 C 中)从包含以下行的文件中读取:

GFE_1GFE_8GFE_19 

I want to use fscanf to ignore the letters and _ and put the number at the end into a variable.

Obviously what I have isn't right:

fscanf(f, "%d", number);

如果它们被空格分隔,我知道如何跳过它们,但在这种情况下我被卡住了。

最佳答案

怎么样

fscanf(f, " %*[^A-Z]_%d", &number);

或者如果前导字符总是相同的,那么就很简单

fscanf(f, " GFE_%d", &number);

关于c - 使 fscanf 忽略 int 前没有空格的字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16315269/

25 4 0
文章推荐: jquery - 如果向下滚动网站,固定标题下方的图像动画
文章推荐: python - 连接点和区间数据
文章推荐: html - 有没有办法将一些
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com