Simple or complex program? need suggestion

This is a discussion on Simple or complex program? need suggestion within the C++ Programming forums, part of the General Programming Boards category; im trying to write a program so i can learn C++ on my own, im also a big fan of ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    494

    Simple or complex program? need suggestion

    im trying to write a program so i can learn C++ on my own, im also a big fan of MP games. i play this game called SOF2.

    when u 1st enter ur cdkey, the game generates a unqiue id called GUID, thus a player has only 1 guid but he can have many names/aliases. when u connect to a server u can check other player guid by just doing /plist . a list of the player comes up on the console as follows.

    985c358f Invariant
    75gdf903 UnNamedPlayer

    since im only a player i can only get the last 8 digits/letters of a players guid, even my own.

    i can save those results by taking a screenshot of the console.

    so what im trying to do is create a players-aliases database, for example a player can change his name or join another team and be part of 2 or more teams. but since he cant change his guid a crossrefernce of guids will give ALL the player's aliases.

    it doesnt have to be a complex prog with user interfaces and search functions, for now im only interested in creating the list/database.

    so the prog will ask
    Enter player GUID: <you enter the guid>

    Enter player alias: <you enter player alias>

    (this will b saved in a txt file. 1st the guid and then the players name, guid's need to have 2 line sapcing between the next guid at all time, cuz a player might have for example 10 aliases.

    if a guid already exist, after u enter the guid it will say
    GUID already exists, enter player alias: <enter player alias>

    the previous alias should not b deleted or over-written but it should b appended on that guid, so b4 u had 1 alias and now u have 2 aliases but still only 1 guid.

    i have no idea if my logic or my ideas are correct so any suggestions are more than welcome, dont forget im new and this is done only for learning, with that said what knowledge of C++ will b required most to create this prog, what kinda functions or classes do i need to write.

  2. #2
    Registered User
    Join Date
    Apr 2004
    Posts
    2

    Wink Use std::map

    The STL (standard template lib - every modern C++ compiler come with it) is having a data structure called map this is data strcure with key (you place your GUID there) and data (use std::vector, which is a dynamic array) as your data. To save to file define strucure that holds both key (GUID) and the aliases and define operator << and >> on this structure. If you are lost then find a good C++ book because those are terms that anyone that wants to write programs should understand

  3. #3
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    how much do you know? assuming you know how:

    1) open the file
    2) put the file in memory and close the stream
    2) search for the guid
    3) if found, go to the bottom of the list of names and put the new one in there - if not, put a new guid in with a new name under it
    4) if your done editing the file, rewrite it.

    you could structure your file like so:

    Code:
    v4r864t8e
         name1
         name2
    4vcr8af7r
         name 1
    486c7e7a
         name1
         name2
         name3
         name4
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    494
    Quote Originally Posted by major_small
    how much do you know? assuming you know how:

    1) open the file
    2) put the file in memory and close the stream
    2) search for the guid
    3) if found, go to the bottom of the list of names and put the new one in there - if not, put a new guid in with a new name under it
    4) if your done editing the file, rewrite it.

    you could structure your file like so:

    Code:
    v4r864t8e
         name1
         name2
    4vcr8af7r
         name 1
    486c7e7a
         name1
         name2
         name3
         name4
    thanks for the structure tip, that makes more sense than what i was thinking and its easier to read. i know how to open and create a file. your suggestions are all valid ill try learning more on how all what u mention is done.

  5. #5
    Registered User
    Join Date
    Mar 2004
    Posts
    220
    I would just use ofstream from the fstream header and make a parser program to search through the .txt file..very simple. The only complex part would be the .txt parser.
    OS: Windows XP Pro CE
    IDE: VS .NET 2002
    Preferred Language: C++.

  6. #6
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by Tronic
    I would just use ofstream from the fstream header and make a parser program to search through the .txt file..very simple. The only complex part would be the .txt parser.
    actually, you would be using the ifstream class from the <fstream> header, and parsing the .txt file wouldn't be hard... you could even make it easy on yourself by doing something like this in the file:
    Code:
    GUID]v4r864t8e
         name1
         name2
    GUID]4vcr8af7r
         name 1
    GUID]486c7e7a
         name1
         name2
         name3
         name4
    and then whenever you read in a line, if the first 5 characters are "GUID]" then you know that's a new ID, so you treat it as one, and link it to everything that comes after it until you hit another line with "GUID]" as the first 5 characters... just as long as nobody has that as the first 5 chars in their name, you'll be fine...

    one more thing... I like to use .dat... people are less likely to mess around with a .dat file...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 01:27 PM
  2. [Help] Simple Array/Pointer Program
    By sandwater in forum C Programming
    Replies: 3
    Last Post: 03-30-2007, 03:42 PM
  3. simple silly program
    By verbity in forum C Programming
    Replies: 5
    Last Post: 12-19-2006, 06:06 PM
  4. Simple window program
    By baniakjr in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2006, 03:46 PM
  5. Simple simple program
    By Ryback in forum C++ Programming
    Replies: 10
    Last Post: 09-09-2004, 06:48 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21