Thread: Exit a function

  1. #1
    Registered User
    Join Date
    Oct 2002

    Exit a function

    here's what i have...
    void header (void)
    printf("Enter the year (21st century): ");/*Asks user for the year*/
        	if (year > 2100 || year < 2001) /*if not a valid year give error*/
    			printf ("Calendar unavailable for invalid years.\n");/*print error*/
    its followed by another input function...i want to exit this function and stop the program if its not a valid year...i used exit (0); but it gives a warning .. of warning C4013: 'exit' undefined; assuming extern returning int ....i just want to exit and not continue if the condition is true...

  2. #2
    Casual Visitor
    Join Date
    Oct 2001
    include stdlib.h for exit

    I think a better option would be to return an int value. That way you can choose some sort of error routine instead of aborting. Your user most likely won't run your program too many times if he or she has to keep restarting it to enter a valid year. Just an idea.
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Waterloo, Texas
    #include <stdlib.h>
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
        return std::pow
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;

  4. #4
    Registered User
    Join Date
    Oct 2002
    Thanxguys...that worked...i'm such a n00b in C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Odd memory leaks
    By VirtualAce in forum C++ Programming
    Replies: 11
    Last Post: 05-25-2006, 12:56 AM
  3. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Replies: 5
    Last Post: 02-08-2003, 07:42 PM