Thread: Suggestions on a bit of FILE I/O anyone??

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    As noted in the comment that you opted not to read.

    [edit]Oh wait... Nevermind. That was probably blanketed over to me, but definitely directed at the OP. Sorry[/edit]

    In my code, you would simply do something like this:

    Code:
        char *p; // <--= declare this somewhere
    
        if((p = strtok(buffer, ";")))
          strncpy(array->quest, p, sizeof(array->quest));
        else
          *array->quest = 0;
    
        for(i = 0; i < 4; ++i)
          if((p = strtok(NULL, ";")))
            strncpy(array->choice[i], p, sizeof(*array->choice));
          else
            *array->choice[i] = 0;
    
        if((p = strtok(NULL, ";")))
          array->ans = *p
        else
          array->ans = 0;
    Last edited by master5001; 10-20-2008 at 12:47 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. Question about file I/O from a newbie
    By henrik in forum C Programming
    Replies: 4
    Last Post: 11-13-2007, 12:48 AM
  3. File I/O Question
    By Achy in forum C Programming
    Replies: 2
    Last Post: 11-18-2005, 12:09 AM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  5. Replies: 3
    Last Post: 03-04-2005, 02:46 PM