 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Punky Expert Cheater
Reputation: 0
Joined: 27 Nov 2007 Posts: 178
|
Posted: Sat Aug 13, 2011 10:33 pm Post subject: [HELP] C++ HWK, arrays |
|
|
I'm having trouble with my arrays. This program is supposed to read two text files, one containing male first names, last names and addresses and the other with details for females. If the last names and addresses match, then the couple is married. My program is written, it's just that it doesn't match up most of the couples.
Example of the text files
| Code: |
Linda Eastwood 2020 Make My Day Drive
Cher Bono 10 Mayor Street
Ava Gabor 9238 Parkside |
This results in six arrays, first names, last names, and addresses for the ladies and for the men. The only way I figured out to read these files is:
| Code: |
while(!infile.eof()) {
infile >> groomFirstName[count] >> groomLastName[count];
getline(infile, groomAddress[count]);
count++;
}
|
Maybe there's a better way?
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Aug 14, 2011 6:29 am Post subject: |
|
|
For reading, not really since you are using spaces as your delimiter. Which if the person has more then one space in their name it can break your parser.
For example, I have a friend with the last name Den Dulk, so in your script it would look like:
| Code: | Linda Eastwood 2020 Make My Day Drive
Cher Bono 10 Mayor Street
Ava Den Dulk 9238 Parkside |
Which does not support his last name properly since it reads based on the spaces.
You should probably look into a different storage method rather then parsing it as it is. I would recommend if you plan to hold data like this, use XML or CSV. Or even a database file like sqlLite or another small/flat database format.
_________________
- Retired. |
|
| Back to top |
|
 |
Punky Expert Cheater
Reputation: 0
Joined: 27 Nov 2007 Posts: 178
|
Posted: Sun Aug 14, 2011 12:55 pm Post subject: |
|
|
I'm not really familiar with those methods, we just learned arrays in my intro to c++ programming.
Edit: Nvm I figured it out thank you though
The problem was a simple error due to a function not returning the right values.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|