c - C - 涉及 fscanf 的不需要的输出
问题描述
我正在做我的学校作业,我遇到了 fscanf 的问题,可以说是文件管理。我一直在这几个小时,查找各种功能和 fscanf 本身,我仍然无法解决这个问题。
#include<stdio.h>
int main()
{
FILE *f3;
float amount_with[100][30];
int j;
char date_with[100][30];
f3 = fopen("withdrawals.txt", "r");
if (f3 == NULL)
{
printf("ERROR! File could not be opened.\n");
}
for(j=0; j <= 50 || !feof(f3); j++)
{
fscanf(f3, "%s %f", date_with[j], &amount_with[j]);
printf("%d %s RM %.2f", j+1, date_with[j], amount_with[j]);
}
}
我想向程序输入一行浮点数、整数和字符串的数据。(例如,本程序中的 18/11/18 200.00)通过 fscanf 或任何其他可能的方式从文本文件中获取。但是,当我执行代码时,程序挂起,除了 CTRL+C 之外,我无法在其中执行任何操作。
谢谢你的帮助。
解决方案
推荐阅读
- javascript - 背景附件:固定;不在 Firefox 中工作,但在 chrommw 和 edge 中工作
- php - 如何使用 php 获取 FEDEX_ONE_RATE API
- excel - 如何替换 Pandas 数据框列中的部分文本?
- symfony - 为 API 定义一个特定的主机
- angular - PAYEE_ACCOUNT_RESTRICTED:商户账户受限
- node.js - 在 Tensorflow 上对图像进行切片的正确方法是什么
- tensorflow - 在 Tensorflow 2 中定义自己的 pad
- sql - 输出具有最新记录且没有空值 Oracle 的单行
- python - 无法将文件写入本地主机和网络共享
- c# - 无法从 Visual Studio 2019 中的解决方案资源管理器中删除文件