Like Tree1Likes
  • 1 Post By anduril462

String Array fgets

This is a discussion on String Array fgets within the C Programming forums, part of the General Programming Boards category; If you are using fgets to put strings into an array of strings are the strings represented by the first ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    18

    String Array fgets

    If you are using fgets to put strings into an array of strings are the strings represented by the first or second declared dimension of the array.

    For instance is you had array str[32][310] would that be able to read 310 strings of 32 members or 32 strings of 310 members?

  2. #2
    Registered User
    Join Date
    Nov 2011
    Location
    Saratoga, California, USA
    Posts
    334
    str[0][0] would be the start of your first string.
    str[1][0] would be the start of your next.
    and so on,
    str[31][0]

    you can think of it as,
    str[rows][columns]
    or
    str[str_no][letters]

    And that is regardless of how you go about filling the arrays.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,467
    32 strings of 309 characters (remember one byte for the null terminator). str[0] is your first string of 309, str[1] your second, etc.
    CommonTater likes this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fgets erroneoulsy returns null string
    By leonv in forum C Programming
    Replies: 3
    Last Post: 12-04-2006, 05:20 AM
  2. fgets - It will always return [string]\n\0 ?
    By stevong in forum C Programming
    Replies: 7
    Last Post: 12-01-2005, 11:17 AM
  3. is scanf as safe as fgets when used to receive string?
    By Antigloss in forum C Programming
    Replies: 4
    Last Post: 08-31-2005, 05:18 PM
  4. String manipulation and scanf vs fgets
    By Nit in forum C Programming
    Replies: 9
    Last Post: 03-20-2002, 11:44 AM
  5. Problem with fgets and getting the string
    By Garfield in forum C Programming
    Replies: 2
    Last Post: 10-03-2001, 02:22 PM

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