View Single Post
Old 11-30-2012, 12:53 PM   #1
justin_ator
🥓<strong><span style="col
Resident Overseer
FFR Veteran
 
justin_ator's Avatar
 
Join Date: Mar 2007
Location: Kingsport, TN
Posts: 7,648
Default C++ fstream and arrays

Okay, so I'm making this thread for two reasons:
1) I'm frustrated because I can't figure out what I'm doing
2) I want to learn how to do this correctly

I was making a program for ssbmchamp's Powerball thread that would make things easier for comparing and figuring out payouts, etc.

This is a general idea of my pseudo code:
Code:
initialize input file and output files

take in lines for each user, with their guesses

guesses assigned to an array guess[i]
guess[i] is compared to numbers[i through i+4], to see if there are any matches
output and credit distribution is based on how many matches they have, etc.
My issue is as follows:
Lines are being read in as
justin_ator [#,#,#,#,#][#][#]
and I need a way to split the lines into the username, numbers, and useless info.

I'm fine with the concept of doing
Username
[#,#,#,#,#][#][#]
so that the username isn't an issue for reading, but I still don't know what I'm doing after that. I tried looking into tokens and delimiters, etc, but I just don't know how to assign the #'s to the array guess[i] without dealing with the [ and , and ]... I'm kind of confused.

This was probably confusing. If I need to clarify something more, please do ask.

I didn't post my code because I don't want you to write the program for me.. I want to learn how istringstream, tokens, iss, etc work if that's the best route to go. I tried looking into it and I was just kinda lost.
justin_ator is offline   Reply With Quote