Beginner Requiring a little help

This is a discussion on Beginner Requiring a little help within the C Programming forums, part of the General Programming Boards category; I have recently started to learn C and am finding it very interesting but have come across a few problems ...

  1. #1
    Unregistered
    Guest

    Beginner Requiring a little help

    I have recently started to learn C and am finding it very interesting but have come across a few problems regarding certain declerations and would appreciate it if somebody could simply explain to me what the return value is and what the arguments mean on the following

    long *all_long(int num, int i[]);

    void many_args(char *s, int[], double f);

    FILE *file_func(char *fn[], char *m[], int num);

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    I'll do the first one for you (just because this sounds a lot like homework):

    It returns a pointer to a long, and takes a integer "num" and an integere array "i" as arguments.

    Lather, Rinse, Repeat....

  3. #3
    Unregistered
    Guest
    Thanks For the help, so its virtually a case that the info before the brackets is what is to be returned and inside is my list of arguments

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    > Thanks For the help, so its virtually a case that the info before
    > the brackets is what is to be returned and inside is my list of
    > arguments

    Not sure exactly what you're trying to say. This is basicly how the function would be used:
    Code:
    long *all_long( int num, long i[] )
    {
        int x;
    
        for( x = 0; x < num; x++ )
        {
            /** if the value of i[x] is some random value, return its location **/
            if( i[x] == 20 ) return &i[x];
        }
        return NULL;
    }
    Basicly, return the address of this variable...

    Anyway, that's one way it could be used. Usually, when you see an array and a number as an argument, the number specifies how long the array is, so you don't run out of bounds when using it.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User breed's Avatar
    Join Date
    Oct 2001
    Posts
    91
    these are prototypes (when first declared before program main)

    void many_args(char *s, int[], double f);

    int main()
    {
    char name[]={"chugly unt"}; //a string
    int num[10]; //array of 10 numbers
    double float[10]; //array of 10 doubles

    while(num !=10) //start a loop
    {
    many_args(name, num,float); //the function call this will pass the args as long as they are of the correct data type

    num++;
    }
    }//end main
    void many_args(char *s, int[], double f)
    {
    //now you can manipulate the arguments in the function at your will

    }

    This is my interpretation any how, hope it helps and doesn't confuse.
    by the way this looks like a computeach question is it?
    Before you judge a man, walk a mile in his
    shoes. After that, who cares.. He's a mile away and you've got
    his shoes.
    ************William Connoly

  6. #6
    Unregistered
    Guest
    Yes its a computeach question
    Are you currently doing the same course and if so how's it going?
    Have you got an E-Mail address i could contact you on as im strugguling a bit at the moment and would appreciate any help you could give me if possible
    Thanks
    Matt

  7. #7
    Registered User breed's Avatar
    Join Date
    Oct 2001
    Posts
    91
    No sweat matt we hsould all try and stick together,
    due to the fact that the coarse dosen't help you out with that much detail.
    you can contact me at garygpuk@hotmail.com

    ....have you seen the unoficial computeach site yet?
    ...It's not a brilliant aid, but a good laugh!, it does help to have peeps that know what you are asking about though.

    by the way what stage r u on?
    what C&G are doing 4240 or the 4250?

    i'm on stage 4 now ready for the prog prep date(should be fun ( NOT))

    here's a link to the web site i mentioned earlier
    unoficial computeach

    speak to u l8er matt
    Before you judge a man, walk a mile in his
    shoes. After that, who cares.. He's a mile away and you've got
    his shoes.
    ************William Connoly

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Same old beginner question...
    By Sharmz in forum C Programming
    Replies: 15
    Last Post: 08-04-2008, 11:48 AM
  2. Voxel Rendering (Beginner)
    By appleGuy in forum C++ Programming
    Replies: 11
    Last Post: 06-29-2007, 11:03 PM
  3. What are some good beginner programs I shouold make?
    By oobootsy1 in forum C# Programming
    Replies: 6
    Last Post: 08-09-2005, 02:02 PM
  4. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 10:21 AM

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