Thread: quoted-comma-delimited files

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    4

    Arrow quoted-comma-delimited files

    I am new to C++ and was needing to work with some quoted-comma-delimited files, but the only examples I can find are # delimited.

    "1313 Mockingbird Ln","Any Town","CA"

    How do you account for the quotes and comma so that you can use just the information?

    Any help would relieve a little stress

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    52
    "1313 Mockingbird Ln","Any Town","CA"
    Try something like this: you need to #include <string.h>
    Code:
    char* delim="", ";
    char* hold;
    char* mystring=""1313 Mockingbird Ln","Any Town","CA"";
    hold=strtok(mystring, delim);
    for (someconditions;){
         hold=strtok(NULL, delim);
         printf("%s \n",hold);
    }
    this should print out: 1313
    Mockingbird
    Ln
    Any
    Town
    CA
    Turn no more aside and brood
    Upon love's bitter mysteries
    For Fergus rules the brazen cars...

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    4

    Re: quoted-comma-delimited files

    Originally posted by my68gto
    I am new to C++ and was needing to work with some quoted-comma-delimited files, but the only examples I can find are # delimited.

    "1313 Mockingbird Ln","Any Town","CA"

    How do you account for the quotes and comma so that you can use just the information?

    Any help would relieve a little stress
    Thanks for the info. One problem I am having with the code you submitted it the double quote. The complier doesn't like having """ it seems to treat like the first 2 go together, but the third one is an orphan looking for a mate - any suggestions

    Thanks again

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Like this
    char *quotes = "hello \"world \" ";

  5. #5
    Registered User
    Join Date
    Aug 2002
    Posts
    4
    Originally posted by Salem
    Like this
    char *quotes = "hello \"world \" ";

    Quote

    I am working with a file that is formatted like this:

    "John","Doe","1313 Mockinbird Ln"."Yourtown"."CA","12345-6789"

    how do I detect the " ? This is my problem.

    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Create Copies of Files
    By Kanshu in forum C++ Programming
    Replies: 13
    Last Post: 05-09-2009, 07:53 AM
  2. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  3. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  4. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  5. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM