Thread: second function

  1. #1
    Registered User
    Join Date
    Feb 2005

    second function

    if i create a struct with various char arrays in it and later call to one particular array using the gets function for example the variable s of the struct Robert which contains people's first and last names each up to 30 characters long (fname[30] and lname[30]) and call it using gets(s-> fname, 25) is the 25 an instanciation or a call to the 26th char of the array? sorry if it's obvious, i'm new at c

  2. #2
    Registered User
    Join Date
    Sep 2004
    First of all, the gets() function only takes one parameter - not two. Second of all, you should never use the gets function, use fgets() instead. The fgets prototype looks like:

    char * fgets (char * string , int num , FILE * stream);

    You can read more about the function here.

  3. #3
    Registered User
    Join Date
    Feb 2005

    not helpful

    i only put in two parameters because that's what was in the program in front of me which supposedly worked but thanx for trying and if you do find the answer i'd love to know

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > that's what was in the program in front of me which supposedly worked
    How about posting the program then.

    Posting random snippets from the program which you do not understand, then expecting us to guess the rest and provide you with an answer just isn't going to happen.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM