Former Site Admin
Posts: 3814
Joined: 08 Jan 2009, 23:00
Location: California - Pacific Time (UTC -8/-7 Summer Time)
Ben Uses C++
So I figure maybe you guys could help me once in a while if you have the knowledge
Anyway, my first problem is figuring out how to write to a binary file. Basically, I am converting a program I made earlier from read and write to a text file so that it now uses binary.
In the ext file version, I used a structure to and cin.getline within a function to write to the text file. I'm having trouble figuring out what the "binary equivalent" of this would be:
- Code:
struct Player { char name[ML]; char number[ML]; int points; }; ... void addPlayer(Player s[], int &num) { cout << "Player Name: "; cin >> ws; cin.getline(s[num].name, ML); //gets player name cout << "Player Number: "; cin.getline(s[num].number, ML); // gets player number cout << "Points Scored :"; cin >> s[num].points, ML; //gets points scored by player num++; //number increases so the next time the function is used it makes a new player instead of overwriting the old one return; }