Confusing question for me. Basically, I'm an alleged to compose a function that reads a document (\"Sample.txt\") and stores it right into a 2D array and determines the variety of entries(rows). The variety of entries need to be less than or equal to 200. The 2D selection should no be identified as global variables. Also, usage a separate function to initialize all arrays.My attempt thus far;

int readfile(double xy<><200>, char filename<>)int Array_X<200> = initilisation();int Array_Y<200> = initilisation();int count = 0;while (count > Array_X >> Array_Y)count++;return Array_X;return Array_X;HELP will certainly BE APPRECIATED!Also, The \"Sample.txt\" file reads something favor this;1 32 43 54 85 11I'm making use of c++This short article has to be edited by KAISER91: 05 may 2011 - 12:24 PM


\"*\"

#2JackOfAllTrades


Saucy!
\"*\"

1. What is ArraySize?2. Why aren't you utilizing the function arguments? What is your purpose?To be perfectly honest this simply seems like a hastily thrown-together attempt or a copy/paste of some code you discovered that looks choose it might do other similar.

You are watching: Read text file into 2d array c++


#3KAISER91


JackOfAllTrades, ~ above 05 may 2011 - 12:19 PM, said:


1. What is ArraySize?2. Why aren't you utilizing the role arguments? What is your purpose?To it is in perfectly honest this simply seems prefer a hastily thrown-together attempt or a copy/paste of some code you found that looks like it might do miscellaneous similar.
I've been trying to attempt this concern from expertise of previous exercises I have actually done and yes I have tried to use use my codes from those practice to do them fit here however obviously I'm lost. I'm doomed!ArraySize must be 200.
Try programming in stages. Firstly, just open the document and print it come the screen. Carry out you require Array_X<> and Array_Y<>? Also, they space integers and xy<> is double.Input/Output with files
Try programming in stages. Firstly, just open the document and publish it come the screen. Execute you require Array_X<> and also Array_Y<>? Also, they space integers and xy<> is double.Input/Output v files
OK, i will carry out it by stages. Ns have controlled to check out the record and publish the values on the screen.

#include#include#includeusing namespace std;int key () { cable line; ifstream myfile (\"Sample.txt\"); if (myfile.is_open()) { if ( myfile.good() ) { getline (myfile,line); cout just how do I now determine the number of entries (rows)? The maximum number of data points have to be 200. Would this be a an excellent header?int readfile(double xy<><200>, char filename<>)
This isn't going to work:

int Array_X<200> = initilisation();Though i am really curious as to what initilisation() is intended to return. Rather, you would certainly pass selection to a role that initialized it. Usually with the size, since the duty wouldn't be able to figure that the end from simply the variety reference.
Very good, i would try transferring the password to a role now.

KAISER91, on 06 may 2011 - 07:34 AM, said:


You can count the lines/rows as you check out them native the file.

See more: What Are We Going To Do On The Bed Meme S, What Are We Gonna Do On The Bed

KAISER91, top top 06 might 2011 - 07:34 AM, said:


The maximum variety of data points need to be 200. Would this be a good header?

int readfile(double xy<><200>, char filename<>)
This appears a good header (it can always be changed), although you could use the maximum variety of data points as a parameter and then usage 200 as an argument.