Have no idea (please help)

This is a discussion on Have no idea (please help) within the C Programming forums, part of the General Programming Boards category; Hello. I'am writing a program where after an certain function has been excuted the user needs to go back and ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    92

    Have no idea (please help)

    Hello. I'am writing a program where after an certain function has been excuted the user needs to go back and enter values in an earlier function. My question is that is it possible to write code that after function 2 has has been excuted that the user can enter values into function 1 again. If so can someone please give some hints on how to do such an operation.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    void fun1( void )
    {
        while foo
        {
            fun2( );
            enter values
        }
    }

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

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    92

    Are you sure

    Are you sure that's possible. If so can someone include a small example.

  4. #4
    Sr. Software Engineer filker0's Avatar
    Join Date
    Sep 2005
    Location
    West Virginia
    Posts
    235
    You've not sufficiently described your problem. What Quzah suggests is a perfectly valid way of doing things, but may not be the solution to your problem. Describe your algorithm.

    Remember that functions can be called multiple times with different arguments to get different results with no ill effects.
    Insert obnoxious but pithy remark here

  5. #5
    Registered User
    Join Date
    Sep 2005
    Posts
    92

    Proper description

    Hello. I"am sorry if you did'nt understand what I meant. What I really meant is that if a program has 3 functions. And after entering values in the 3rd function the user is now required to enter values into the 2nd function again. Now my question was that is it possible to write a code that can do that? If so can someone give me some hints on how to do it.

    My other question is that can a fourth function be written with-in the second function, but keeping in mind that the fourth function will not be used until the user has entered values into the 3rd function.

  6. #6
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    469
    there are probably loads of ways to do that, namely just calling the functions in the right order in main, and about calling the fourth function in function 2, thats fine, but function definitions are always outside other functions. here's a program structure i came up with which may help you out:

    Code:
    #include <abunchofheaders.h>
    
    void func1 ();
    void func2 ();
    void func3 ();
    void func4 ();
    
    int main ()
    {
        func1 ();
        func2 (0);    /*this prevents calls to func4 before func3 has been executed*/
        func3 ();
        return 0;
    }
    
    void func1 ()
    {
        /*some code*/
    }
    
    void func2 (int argument)
    {
        /*some code*/
        
        if (argument == 1)
        {
           func4 ();
        }
        else
        {
            /*some more code*/
        }
    }
    
    void func3 ()
    {
        /*some code*/
        func2 (1);   /*at the end of func3, call func2 like this*/
    }
    
    void func4 ()
    {
        /*some code*/
    }
    ;
    No No's:
    fflush (stdin); gets (); void main ();


    Goodies:
    Example of fgets (); The FAQ, C/C++ Reference


    My Gear:
    OS - Windows XP
    IDE - MS Visual C++ 2008 Express Edition


    ASCII stupid question, get a stupid ANSI

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. project idea ???
    By gemini_shooter in forum C Programming
    Replies: 2
    Last Post: 06-09-2005, 10:56 AM
  2. Have an idea?
    By B0bDole in forum Projects and Job Recruitment
    Replies: 46
    Last Post: 01-13-2005, 03:25 PM
  3. A little problem about an idea, help please
    By louis_mine in forum C++ Programming
    Replies: 3
    Last Post: 09-10-2004, 10:52 PM
  4. totally screwed up idea
    By iain in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 08-17-2001, 01:09 PM

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