LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Last assignment and I am lost (http://www.linuxquestions.org/questions/programming-9/last-assignment-and-i-am-lost-216749/)

Veteq 08-12-2004 12:05 PM

Last assignment and I am lost
 
I need same help (again)

I am suppose to use pass-by-reference from a sub-rotine to the main() but I am really lost

Code:

/*************************************************
 *  *        Asgn10.c                              *
 *  *        Written by :        *
 *    *************************************************/
#include <stdio.h>
#define PROGRAMMER "LOST"


void name();
int input();

/* define arrays */

int keeper[5];

/**************************************************
 *                  main rotine
 **************************************************/
main()
{
        int keeper[5];

        name();
        input();
        printf("%d\n", &keeper[5]);


}

/************************************************
 *              name rotine                    *
 ************************************************/
 void name()
{
        system("clear");
        printf("%s\n\n", PROGRAMMER);
}

/************************************************
 *              Input rotine                    *
 ************************************************/
int input()
{
        int f;
        for ( f = 0; f < 5; f++)
        {
            printf("Enter integer number %d : ", f+1);
            fflush(stdin);
            scanf("%d", &keeper[f]);
        }

        return &keeper[];


}

The idea is to pass the address of the data in the array to the main rotine but I am having a hard time on this one....please help...

Veteq

kev82 08-12-2004 12:17 PM

before you try fiddling with passing arguments by reference i suggest you learn more basic stuff like syntax a bit better because "int input();" in main makes no sense, and "printf("%d\n", &keeper[5]);" certanly isnt what you want to do.

whens the assignment due?? and have you been to see your tutor?

<edit>if this sounds harsh im sorry but from the current state of the program i see no way to guide you to the answer and i dont want someone to just blurt out the answer as that wont help you.</edit>

Veteq 08-12-2004 01:55 PM

I got it all working, thank you. Once I understood the concept, it was easy.


Veteq


All times are GMT -5. The time now is 02:04 AM.