i really am lost as to what to do here. the program i need to write is that i have to open up a text file (i'll display that a the bottom of the post), read the info in the text file and put it into strings, and after sorting through all of that, write the information into a different text file. here is a link to what i need to do. (just program 1 at the moment)
https://webcourses.niu.edu/courses/1...1/240pgm10.htm
so the input text takes a player name, and then some various stats of theirs. so the suggested logic in the link i posted is to create a c style string. ok. what exactly would that be? i know the basic string would be something like:
char s[50]="blah blah blah"
so i guess my first question is, how do i put the input file into such a string? and what would be the subscript inside? i just randomly made up 50 here, but i have no clue what to use for this program.
my extremely basic code so far is this
Code:
#include <iomanip>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <math.h>
using namespace std;
int main()
{
ifstream inputFile;
inputFile.open( "players.txt" );
if( inputFile.fail() )
{
cout << "players.txt failed to open";
exit( -1 );
}
ofstream myfile;
myfile.open( "team.txt", ios::binary );
if( inputFile.fail() )
{
cout << "team.txt failed to open";
exit( -1 );
}
return 0;
}
this is the text file that i have to read from
Code:
Patrick Kane:28:54:233
Duncan Keith:13:52:193
Patrick Sharp:22:39:241
Jonathan Toews:22:37:185
Marion Hossa:22:22:174
Troy Brouwer:21:18:108
Brian Campbell:7:31:131
Kris Versteeg:17:21:164
Andrew Ladd:16:18:130
Dustin Byfuglien:16:13:188
Brent Seabrook:4:20:118
John Madden:10:13:118
Kim Johnsson:7:10:94
Tomas Kopecky:7:8:79
Niklas Hjalmarsson:2:12:52
Colin Fraser:2:11:80
Dave Bolland:4:9:42
Ben Eager:5:5:57
Nick Boynton:1:7:50
Brent Sopel:1:5:38
Jordan Hendry:1:5:33
Bryan Bickell:2:1:16
Jake Dowell:1:1:4
Jack Skille:1:1:9
Adam Burish:1:1:4
Cristobal Huet:0:0:0
Antti Niemi:0:0:0
Corey Crawford:0:0:0
go hawks!