|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have a file(name "rock.txt") that needs to be inputed that looks like this:
1 4 2 1 2 3 2 2 3 4 1 3 4 3 3 0 5 3 2 1 6 4 1 2 7 5 2 1 8 4 3 2 9 3 4 1 10 4 3 3 11 6 2 0 12 4 1 1 13 2 2 0 14 1 3 2 15 2 4 0 16 3 3 1 17 4 2 4 18 2 4 1 19 3 3 0 20 4 2 0 and needs to go into a programming array. I have gotten this far #include <iostream> #include <iomanip> #include <cmath> #include <string> #include <fstream> using namespace std; int playerNumber; int numHits; int numWalks; int numOuts; int players=20; void calcAverage(); float batAverage; int rowCounter=0; int team [20] [4]; int columnCounter=0; ifstream inFile; int main() { inFile.open("rocks.txt"); while (rowCounter<20) { while (columnCounter<4) { inFile >> team [rowCounter] [columnCounter]; cout << team [rowCounter] [columnCounter]; columnCounter++; } cout<<endl; columnCounter=0; rowCounter++; } return 0; } but I am stuck because when executed it comes out with 20 x 4 zeros instead of the input file. I want it to spit out the information in my file above. Please help? |
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > Arrays |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|