LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-12-2004, 12:05 PM   #1
Veteq
Member
 
Registered: Feb 2004
Posts: 155

Rep: Reputation: 30
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

Last edited by Veteq; 08-12-2004 at 12:59 PM.
 
Old 08-12-2004, 12:17 PM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
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>

Last edited by kev82; 08-12-2004 at 12:19 PM.
 
Old 08-12-2004, 01:55 PM   #3
Veteq
Member
 
Registered: Feb 2004
Posts: 155

Original Poster
Rep: Reputation: 30
I got it all working, thank you. Once I understood the concept, it was easy.


Veteq
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
automatic Ip assignment rupeshdwivedi Linux - Networking 1 08-31-2005 04:20 PM
Domain Assignment dramous Linux - Newbie 1 09-27-2004 02:36 AM
IP address assignment n3tw0rk Linux - Networking 1 01-05-2004 12:23 AM
need help with class assignment tenraek Linux - General 4 04-03-2003 12:31 AM
IP assignment - permanent? dalraidia Linux - Networking 1 12-13-2002 10:55 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration