FIle tokenize?

This is a discussion on FIle tokenize? within the C++ Programming forums, part of the General Programming Boards category; Hi, I would like to 'tokenize' a file with a delimiter....for example: Input File: 90:43:37:58 91:43:22:52 ...etc... and would like ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    1

    FIle tokenize?

    Hi,

    I would like to 'tokenize' a file with a delimiter....for example:

    Input File:

    90:43:37:58
    91:43:22:52
    ...etc...

    and would like to tokenize it so that for the first line i get: "90" "43" "37" "58" which can be in turn inputted into an array.

    How can i split the numbers up using the delimter ":" on each line?

    cheers.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    The easiest way would be to use Boost.Tokenizer from the Boost libraries.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    You could also use strtok(), with appropriate delimiter(s) or you could write your own function, for the practice. I've also seen reports of using a series of >> like---cin >> num1 >> dummy >> num2 >> dummy....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 07:51 PM
  2. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  3. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  4. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

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