Thread: c++ I/O problem

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    80

    c++ I/O problem

    ZONEID ZONEDESC PRICE
    ------ -------------------- -------
    1 Toronto 5.00
    2 North York 7.00
    3 Mississauga 8.00
    4 Etobicoke 8.00
    5 CDF 0.00
    6 Transylvania 12.00
    7 Atlantis 12.00
    8 Mars 50.00

    how can i seperate it in to tokens for all lines? can u write some code pls

  2. #2
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572
    >>how can i seperate it in to tokens for all lines? can u write
    >>some code pls

    can you show us that you tried?

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  3. #3
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    I shouldn't do this, but
    Code:
    ...
    int inum;
    char*word=new char[16];
    float fnum;
    
    ...
    
    cin>>inum>>word>>fnum;
    
    ...
    edit: that wont work the way you want it... look at the New York part...
    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
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146

    Re: c++ I/O problem

    Originally posted by condorx
    can u write some code pls
    NO!
    Bad coder. Bad coder!
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  5. #5
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    Here's some code:
    Code:
    #include <iostream>
    int main()
    {
        std::cout << "Depends on what the delimiters are.  It looks "
                     "like they are all spaces, so I'd read in a line "
                     "at a time, then take the first and last token "
                     "and store them as ZONEID and PRICE.  Whatever "
                     "is left in the middle would be the ZONEDESC.";
        std::cout << std::endl;
    }
    Last edited by jlou; 10-01-2003 at 07:33 PM.

  6. #6
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    ^ try this
    Code:
    #include <iostream>
    int main()
    {
        std::cout << "Depends on what the delimiters are.  It looks"
                     <<"like they are all spaces, so I'd read in a line"
                     <<"at a time, then take the first and last token"
                     <<"and store them as ZONEID and PRICE.  Whatever"
                     <<"is left in the middle would be the ZONEDESC.";
        std::cout << std::endl;
        return 0;
    }
    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

  7. #7
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,090
    This is off topic, but I think mine works fine. Also, you don't need the return 0; according to the standard, even though VC++ 6.0 warns you if you don't put it.

  8. #8
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Posts
    2,572
    Originally posted by jlou
    This is off topic, but I think mine works fine. Also, you don't need the return 0; according to the standard, even though VC++ 6.0 warns you if you don't put it.
    please, lets not start this discussion again....

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

  9. #9
    Seven years? civix's Avatar
    Join Date
    Jul 2002
    Posts
    605

    Re: Re: c++ I/O problem

    Originally posted by joshdick
    NO!
    Bad coder. Bad coder!
    How's he the coder if he wants us to do the coding?
    .

  10. #10
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146

    Re: Re: Re: c++ I/O problem

    Originally posted by civix
    How's he the coder if he wants us to do the coding?
    Point well taken, but I didn't know what else to call him that would've been appropriate.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  11. #11
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    please, lets not start this discussion again....
    As far as I see it there is no discussion...what the standard says is final
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie problem: I/O File
    By Ardetcho in forum C Programming
    Replies: 4
    Last Post: 07-19-2006, 04:27 PM
  2. File I/O problem for dynamically allocated struct array
    By veecee in forum C++ Programming
    Replies: 2
    Last Post: 05-05-2006, 09:28 PM
  3. Binary File I/O Problem
    By 0rion in forum C Programming
    Replies: 10
    Last Post: 08-31-2004, 12:53 PM
  4. i/o problem...
    By Finchie_88 in forum C++ Programming
    Replies: 4
    Last Post: 08-31-2004, 11:50 AM
  5. Interesting problem with file I/O...
    By skillet in forum C++ Programming
    Replies: 12
    Last Post: 02-20-2002, 11:14 AM