list of numbers in a text file into a 2d array

Hi,
I have a text file which contains a list of numbers like this
122
121
111
112
121
2
12
12121
21
21
212
1
I want to read the text file into c++ then create an array with the data that is 121 by 230
how would I do this?

Hmm, homework by the smell of it. Post some of you own code first and then expect help only in very general terms, otherwise expect a moderator to lock the posting.

Also, where do you get the 121 by 230 from? There's not that much data in the file and I don't see anything in the file to indicate those dimensions.

Anyway, I will tell you the the generic syntax for declaring a 2 dimensional array of integers is: int MyArray[x][y]; where int is the data type (can be anything, you can even define your own types with the typedef, struct, and class statements), MyArray is the name of the array, and x and y are the sizes of each dimension (in your case 121 and 230).

To read from a file, you must #include <fstream> or <fstream.H>.
Delcare a stream like this: fstream mystream;
Then open the file using that stream: mystream.open ("file.name", ios::beg|ios::nocreate|ios::noreplace);
The ios:: stuff at the end of the statement are flags you can set. You may want to check your textbook for more info on them. Once the file is open, reading is just like reading in from the keyboard. You would say: mystream >> somevariable; to read in from the file and mystream << somevariableorliteral; to write out to it. You will also find the the .getline(char *s, int l); function comes in handy. It reads a line at a time into a charactar array and you can do what you want with it after that.

Thanks for the help, no its not homework. I am a weather forecaster in the military and trying to createa program for reading forecast weather data. I didn't list every number just an sample to show. That will form a grid of numbers which represent a peice of weather. This one is temperature in kelvin. oh heres my code but I think I am wrong thats why I was asking. I fugured I could get a sample to get me on the right track.
here is the code I use for reading the file but how do I get that data into an array?
#include<string>
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;

int main ()
{
vector<string> v;
ifstream in ("peloponnesian_a.txt");
string line;
while (getline (in, line))
v.push_back(line); //Add the line to the end //Add line numbers:
for (int i=0; i<v.size(); i++)
cout<<i<<": "<<v[i]<<endl;
}
//Copy an entire file into a vector of string

As for putting the data in an array are you sure you need it? You are already using a vector, which is better. What I would do first is change the vector to type int or long (or maybe float) and read the files using stream operators rather than the getline function (see example below). This will keep the data in a format that is easier to compare, manipulate, etc.

That would work but the data has to be in a 121 bty 230 grid because right now they are like i showed above, but they need to be in that grid to make sence because it is a grid that covers the united states and every grid point represents a longitude and latitude.

Then don't use the vector. Remove all the code that references it. If you follow the code you will see there is both an array and a vector, and you really only need one or the other. Question though, how is the data organized in the file? You need to know this to read it in to the array. To demonstrate what I'm trying to say, look at these two pieces of code: