C++ fstream and arrays

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • justin_ator
    🥓<strong><span style="col
    • Mar 2007
    • 7648

    #16
    Re: C++ fstream and arrays

    Originally posted by emerald000
    I would do some preprocessing on the text file before inputting it in the program. It would make it much easier. Just do a mass search and replace into a format such as:

    Username,1,2,3,4,5,6,7

    Then, you can use std::getline(stream, number, ',') to get each part one after the other.
    That makes sense. This is why I was saying the username part wasn't an issue because we can change the format. Didn't realize you could add those parameters to getline to make it that easy though. Thank you. I'll give it a try when I get done eating and showering.

    Comment

    • Patashu
      FFR Simfile Author
      FFR Simfile Author
      • Apr 2006
      • 8609

      #17
      Re: C++ fstream and arrays

      I would write in a better* programming language and use regexes with capture groups to parse each line and spit out the individual elements for you

      *better for non robotic beings

      your regex would be something like
      (\w+) \[(\d+),(\d+),(\d+),(\d+),(\d+)\]\[(\d+)\]\[(\d+)\]
      (make sure to double all backslashes if your language doesn't have a way to specify to ignore them, like @" in C# and r" in python)
      then you can search a line for that regex, take the match and use the contents of each match (first match will be username, second match onwards will be da numbers)
      Patashu makes Chiptunes in Famitracker:
      http://soundcloud.com/patashu/8bit-progressive-metal-fading-world
      http://img.photobucket.com/albums/v216/Mechadragon/smallpackbanner.png
      Best non-AAAs: ERx8 v2 (14-1-0-4), Hajnal (3-0-0-0), RunnyMorning (8-0-0-4), Xeno-Flow (1-0-0-3), Blue Rose (35-2-0-20), Ketsarku (14-0-0-0), Silence (1-0-0-0), Lolo (14-1-0-1)
      http://i231.photobucket.com/albums/ee301/xiaoven/solorulzsig.png

      Comment

      • FissionMailed1
        FFR Player
        • Feb 2012
        • 1267

        #18
        Re: C++ fstream and arrays

        C++11 supports regexes as well if you want to go that route. http://solarianprogrammer.com/2011/1...egex-tutorial/ here is a tutorial for that.


        YOUR THROBBING MULTIFARIOUS LUSTFUL DESIRES ARE COMPLETED N YOUR HYPER-ORANGE SELF, YOU MAKE ME LOVE AGAIN, YOU'VE CHANGED MY HEART, MY MELANCHOLIA DISAPPEARS WHEN YOU ARE INSIDE OF ME, MY HUMAN RAGE IS TEMPERED WHEN I AM INSIDE YOU, THE SECRET IS COMMUNICATION, LONGEVITY, STAMINA, REPETITION, FURY, SOULFUL KISSING, EARPLUGS. YOU FUCKING CORPORATE COCKS AND CUNTS.

        MY ANXIETY COMPLETE, MY DESIRE REPLETE, THE TASTE OF ORANGE BLOOD AND CUM AND GREENBACKS RUNNING DOWN MY FACE. THE STREETS WILL RUN ORANGE WITH YOUR MIXTURE OF CHEETOS AND HUNDRED DOLLAR BILLS REGURGITATED AND EATEN AND SHIT OUT AGAIN AND EATEN AGAIN.

        YOU ARE MY SCULPTURE, MY SCULPTRA, MY SELF-DEFINITION. MY DEFINITION OF HUMANITY, MY HARMONY. MY HEART AND MY MIND.

        YOU ARE SO ORANGE. SO CRUNCHY. SO CONSUMABLE.

        THE NEW ORANGE UNDERGROUND IS THE ORANGE UP MY ASS. AND YOUR ASS.

        I LOVE YOU CHEETOS.

        Comment

        • Patashu
          FFR Simfile Author
          FFR Simfile Author
          • Apr 2006
          • 8609

          #19
          Re: C++ fstream and arrays

          Originally posted by FissionMailed1
          C++11 supports regexes as well if you want to go that route. http://solarianprogrammer.com/2011/1...egex-tutorial/ here is a tutorial for that.
          C++11 is looking sexier every day :O
          Patashu makes Chiptunes in Famitracker:
          http://soundcloud.com/patashu/8bit-progressive-metal-fading-world
          http://img.photobucket.com/albums/v216/Mechadragon/smallpackbanner.png
          Best non-AAAs: ERx8 v2 (14-1-0-4), Hajnal (3-0-0-0), RunnyMorning (8-0-0-4), Xeno-Flow (1-0-0-3), Blue Rose (35-2-0-20), Ketsarku (14-0-0-0), Silence (1-0-0-0), Lolo (14-1-0-1)
          http://i231.photobucket.com/albums/ee301/xiaoven/solorulzsig.png

          Comment

          Working...