Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 7th, 2003, 11:52 AM
davsidm davsidm is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 1 davsidm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Arrays

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?

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > Arrays


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT