Like Tree1Likes

How to read from a file line by line and store lines in separate arrays?

This is a discussion on How to read from a file line by line and store lines in separate arrays? within the C Programming forums, part of the General Programming Boards category; Originally Posted by Matticus These are examples, really, but you should bookmark and review these pages (the second is worth ...

  1. #16
    Registered User
    Join Date
    Jul 2011
    Posts
    29
    Quote Originally Posted by Matticus View Post
    These are examples, really, but you should bookmark and review these pages (the second is worth an in-depth study when you have the time).

    The 'C' Library Referencing Guide
    Frequently Asked Questions
    yep, they do look familiar. things like int fprintf(FILE *stream, const char *format, ...) easy for you to understand but not for me)) yet. what .... supposed to mean? i would have to spend a couple of hours finding out how to read this stuff. thanks anyway)

  2. #17
    Registered User TheBigH's Avatar
    Join Date
    May 2010
    Location
    Melbourne, Australia
    Posts
    426
    The "..." means that the fprintf function can take any number of arguments (well, more than two, anyway). printf is the same. Consider the difference between
    Code:
    printf( "Hello, world!\n" );
    and
    Code:
    printf( "Here are six numbers: %d, %d, %d, %d, %d, %d\n", 5, 7, 11, 42, 0, 32767 );
    The first example, printf takes one argument (the Hello world string) and in the second it takes seven arguments (string, plus six numbers). There is no way of telling in advance how many arguments printf takes, which is why C allows for varying-length argument lists.
    Code:
    while(!asleep) {
       sheep++;
    }

  3. #18
    Registered User
    Join Date
    Jul 2011
    Posts
    29
    Thank you!! Saved me two hours)

  4. #19
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by vegan View Post
    Thank you guys once again, I've searched half the internet looking for fscanf and fgets examples and couldn;t really find one that would help me. i just realized i shouldve prob searched for something like fscanf delimiter not just fscanf c programming.
    c library fscanf - Google Search

    About 117,000 results (0.05 seconds)

  5. #20
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by vegan View Post
    yep, they do look familiar. things like int fprintf(FILE *stream, const char *format, ...) easy for you to understand but not for me)) yet. what .... supposed to mean? i would have to spend a couple of hours finding out how to read this stuff. thanks anyway)
    So... spend the time! Surely you don't plan to spend 15+ messages on forums for every function you don't have memorized...

    Really... learn how to look stuff up.

  6. #21
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by TheBigH View Post
    Did you properly read my post, and the one I was replying to? I know the code wasn't right because it still ran off the end of the file, which I mentioned. The complaint was that it wasn't printing the strings in the input file, but when I compiled and ran it it did print them.
    The comment was meant more for the OP... but I guess my aim was a little off...

  7. #22
    Registered User TheBigH's Avatar
    Join Date
    May 2010
    Location
    Melbourne, Australia
    Posts
    426
    Quote Originally Posted by CommonTater View Post
    The comment was meant more for the OP... but I guess my aim was a little off...
    Oh, OK. That makes a lot more sense.
    Code:
    while(!asleep) {
       sheep++;
    }

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to read a line and store it into an array?
    By david.jones in forum C Programming
    Replies: 5
    Last Post: 05-09-2011, 06:07 PM
  2. Read file line by line and interpret them
    By sombrancelha in forum C Programming
    Replies: 8
    Last Post: 03-17-2011, 10:48 AM
  3. Read text file line by line and write lines to other files
    By magische_vogel in forum C Programming
    Replies: 10
    Last Post: 01-23-2011, 10:51 AM
  4. Read line by line from file with EOL different that OS EOL
    By hanniball in forum C++ Programming
    Replies: 2
    Last Post: 09-17-2010, 10:06 AM
  5. Read first line of a file and store in a variable
    By Saeid87 in forum C Programming
    Replies: 5
    Last Post: 06-19-2009, 12:27 PM

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