fget question

This is a discussion on fget question within the C Programming forums, part of the General Programming Boards category; hi guys, char mystring [100]; fget(mystring , 50, myFile); does it means that i can only read 100 words from ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    19

    fget question

    hi guys,

    char mystring [100];
    fget(mystring , 50, myFile);

    does it means that i can only read 100 words from a myFile? what if myFile consist of alot of words and cant be determined?

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    you will use a loop
    Code:
    while(fgets(mystring,sizeof mystring, myfile))
    {
       /*process mystring buffer */
    }
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    19
    yea but i already declared mystring to an array size of 100. does dat makes any difference?

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Quote Originally Posted by norhos View Post
    yea but i already declared mystring to an array size of 100. does dat makes any difference?
    What difference?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    19
    doesnt it means dat the max number of words will be set to 100? im confuse now lol

  6. #6
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Quote Originally Posted by norhos View Post
    doesnt it means dat the max number of words will be set to 100? im confuse now lol
    no it doesn't - it does nothing to do with words count

    100 - is how many chars (letters) you are reading from the file AT ONCE. doing it in a loop gives you a possibility read all the file
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  7. #7
    Registered User
    Join Date
    Mar 2008
    Posts
    19
    ic thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

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