请帮助文件 [英] Please Help with File

查看:109
本文介绍了请帮助文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是您从输入中一行上包含秒,名称和num_items的文件中进行扫描的方式.例如,如果我要扫描
2 STEVEN 15?

Is this how you scan in from a file that has seconds, names, and num_items on one line in the input. For example, if I want to scan in
2 STEVEN 15?

FILE *fp;

fp = fopen("input.txt", "r");

fscanf(fp, "%d", &seconds);
fscanf(fp, "%s", names);
fscanf(fp, "%d", &num_items);

fclose(fp);

推荐答案

您不会显示接收扫描文本的变量的声明,但是假设它们是这样的:

You don''t show your declarations for the variables receiving the scanned text, but assuming they are like this:

char names[MAXNAMELEN+1];
int seconds;
int num_items;



然后您的代码看起来正确.

Google是您的朋友 [



Then your code looks correct.

Google is your friend[^]


这篇关于请帮助文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆