Okay , so i\'m trying to make a program that creates a 2D array , from a file. t
ID: 3627058 • Letter: O
Question
Okay , so i'm trying to make a program that creates a 2D array , from a file. the program has to open a file with unknown numbers in there, and we wont know the name of the file specified in the program. like i have to use argv[1]. an exmaple is , if i have the numbers 4 3 29 82 71 82 91 32 33 , the row would be 4 and the column would be 3 , the first two numbers have to specify how big my 2d array is.
so the row would be 29 82 71 82 , coloum would be 91 32 33.
So how would i create this kind of 2d array , and fill it .1) i want the content of the array printed row by row , 2) zeored elements and odds of array, 3) the rows that contain at least one odd.
please separate into functions , and explain the code , so i can learn this. thank you
it has to be dynamically made
Explanation / Answer
Dear friend this is the program u want will read a file name and then read all the integers in there and fill it in 2d array the array will be created dynamically using pointers and using the first tow numbers to determine the size the rest i think is easy to complete coz u will deal with a regular 2d array after u red it from the file u will search throw it for the odd numbers and rows ... etc if u needed any additional help just message me and i will be glad to help u :) PLEASE RATE # include # include # include int ReadFromFile(int **Array, FILE *inFile); int main(void) { double arrayVal; int **Array, i, j, x; char filename[50]; //Get input filename printf("Enter the filename to read:"); scanf("%50s",filename); //Open file FILE *inFile; inFile = fopen(filename, "r"); if(inFile==NULL) { printf("Could not properly load file! "); getchar(); getchar(); } else { printf("File opened and loaded properly "); } int value1,value2; fscanf(inFile,"%i,", &value1); fscanf(inFile,"%i,", &value2); Array=new int*[value1]; for(int i=0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.