Thread: how to return function to its beginning

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    14

    how to return function to its beginning

    I am trying to figure out exactly how to return a function to its very beginning after it ends (for any reason at all).

    I will use pseudo code to exemplify:

    printf please enter your age;
    scanf (get age)
    if ( age<18 || age>105) is false
    printf great
    (if true)
    printf you are underage, please
    enter age within range
    return 0

    Ok, now I want to know how I can get back to the beginning of this function so the customer can enter an age within the correct age limit without having to start the program from the very beginning. Can anyone help?

  2. #2
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Try using a do while loop.

  3. #3
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    Code:
    do{
    printf please enter your age;
    scanf (get age)
    if ( age<18 || age>105) is false
    printf great
    (if true)
    printf you are underage, please
    enter age within range
    }while underaged
    EDIT: kermit beat me to it.

  4. #4
    Registered User
    Join Date
    Oct 2010
    Posts
    14
    Ok, great! Thanks guys...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM
  2. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 07:05 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  5. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 07:48 PM

Tags for this Thread