Thread: Delimiter in while loop

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    385

    Delimiter in while loop

    When you are writing a whilestatment like this you have ',' as a delimiter.
    What I wonder is if it is possible to have more than only one delimiter as I also want at the same time use " " and ")". (a blank space and a ")" )
    Is this possible ?


    Code:
    while( getline(ReadFile, OneString, ',')
    {
    }while( getline(ReadFile, OneString, ',')
    {
    }
    I am trying out something like this, however this does not work/compile:

    Code:
    char limiter = ( ',' ')' ' ');
    
    while( getline(ReadFile, OneString, limiter)
    {
    }
    Last edited by Coding; 03-07-2008 at 11:00 AM.

  2. #2
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    I don't think you can do what you want with getline, but you can read in the whole line and then use OneString.find_first_of (if you want them one at a time) or Tokenize (to get all the strings at once).
    Don't quote me on that... ...seriously

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    385
    okay, I will take a look at that and see what I can get out of it..
    Thanks for help !

  4. #4
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    Tokenize isn't a standard C++ function. I got if off this website.
    You can also check the FAQ for more detail on tokenizing.
    Don't quote me on that... ...seriously

  5. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    385
    Thank you, I will check it out.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My loop within loop won't work
    By Ayreon in forum C Programming
    Replies: 3
    Last Post: 03-18-2009, 10:44 AM
  2. loop in a linked linked lists
    By kris.c in forum C Programming
    Replies: 6
    Last Post: 08-26-2006, 12:38 PM
  3. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  4. A somewhat bizzare problem!!! - WHILE LOOP
    By bobthebullet990 in forum C Programming
    Replies: 3
    Last Post: 03-31-2006, 07:19 AM
  5. when a while loop will stop ?
    By blue_gene in forum C Programming
    Replies: 13
    Last Post: 04-20-2004, 03:45 PM