【发布时间】:2022-11-20 12:55:39
【问题描述】:
I'm pretty new to programming in C and I have a school assignment that requires me to use I/O Redirection and strictly use scanf to read the data from a text file.
I'm mostly checking whether or not the code I've written makes sense and is a plausible method because I can't check whether it works currently (may or may not have dropped my laptop).
Here's what I've written so far.
#include <stdio.h>
#include <math.h>
int main(void){
int readingsLen = 5040;
float readings[readingsLen];
float* readingsPtr = (float*)readings;
while (scanf("%.2f", readingsPtr) != EOF){
readingsPtr++;
}
}
Additionally, here's what the text file looks like. Added the \n to show where the line ends.
22.12 22.43 25.34 21.55 \n
【问题讨论】:
-
To read from files, use
fscanf().
标签: c io-redirection