Answer the question
In order to leave comments, you need to log in
How to read a dynamic two-dimensional array from a C-file?
There is an example of how to count a one-dimensional array, but you need to count a two-dimensional rectangular one.
#include<stdio.h>
#include<stdlib.h>
int main(int argc, char *argv[]){
if (argc == 1) {
printf("No file names");
return 0;
}
int size;
FILE *OpenFile;
OpenFile = fopen(argv[1], "r");
if (!OpenFile) {
printf("Failed to open the file");
return 0;
} else {
size = CountFile(OpenFile)
}
int СountFile(FILE *OpenFile) {
int temp, counter = 0;
while (fscanf(OpenFile, "%d", &temp) != EOF) {
counter++;
}
return counter;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question