Ex. Badges 0 3 5 (for the team name, wins, losses, and ties, respectively)
- into a string line, and from that string line, convert the string into four different arrays (using structures).
For example, my beginning is
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstring>
using namespace std;
const int MAX_TEAMS = 12;
const int SIZE = 81;
struct team
{
char name[SIZE];
int wins[SIZE];
int losses[SIZE];
int ties[SIZE];
};
int main()
{
cout << "******************************************" << endl;
cout << "Hello! This program will allow you to put \nin a file name, open said";
cout << " file, calculate\nthe teams' statistics, and then read the\nteams' data";
cout << " from that file onto the screen. \nThe data will include a team's name,";
cout << " wins, \nlosses, and ties." <<endl;
cout << "******************************************" << endl;
I know how to read in things from files, generally, but I don't know how I would read in an entire string of data versus just one piece at a time. The code I'm familiar with stops at every null space instead of every newline. For example, I've written
ifstream inFile; char name[SIZE]; char fileName[SIZE]; cout << "Enter the name of the file: "; cin >> fileName; inFile.open(fileName); inFile >> name; cout << name << endl; inFile >> name; cout << "\t" << name << endl; inFile.close();
while using the practice txt document with it saying
hello user
hello
Could someone help push me in the right direction for using strings with an explanation or pseudocode? I've yet to find anything in my textbook that describes the situation I'm currently describing.

New Topic/Question
Reply




MultiQuote



|