Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[HELP] C++ HWK, arrays

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Punky
Expert Cheater
Reputation: 0

Joined: 27 Nov 2007
Posts: 178

PostPosted: Sat Aug 13, 2011 10:33 pm    Post subject: [HELP] C++ HWK, arrays Reply with quote

Crying or Very sad 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
View user's profile Send private message AIM Address
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun Aug 14, 2011 6:29 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Punky
Expert Cheater
Reputation: 0

Joined: 27 Nov 2007
Posts: 178

PostPosted: Sun Aug 14, 2011 12:55 pm    Post subject: Reply with quote

I'm not really familiar with those methods, we just learned arrays in my intro to c++ programming.

Edit: Nvm I figured it out Smile thank you though
The problem was a simple error due to a function not returning the right values.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites