error() - is there a function like this in gnu/linux?


Hi all,

I am learning to code in c++ on Linux Mint 13. I am going through an exercise drill in a book called "Programming Principles and Practice using c++ by Bjarne Strustrup". I have a couple of questions.

I am having trouble with the calling the error function mentioned below.

Have your program write "I hear you just had a birthday and you are age years old." If age is 0 or less or 110 or more, call error("you're kidding!").

(It is Drill no5. on pg83 if anyone has access to the book)

Also, I think Bjarne is using a Windows machine to do these exercises.

Ones I've encountered sofar:

keep_window_open()

Does this mean that I have to find alternative functions to the ones mentioned in the book? and is there any website where I can find alternative funtions for windows ones (on a beginners level?)

thanks in advance,
You could replace the error function with a call to printf, and if you want the program to stop just call abort afterwards (http://www.cplusplus.com/reference/clibrary/cstdlib/abort/)

And about functions like keep_window_open()... well i do not know what that's supposed to do, maybe you can simply remove it and you program runs fine.
IIRC, he provides a file named something along the lines of std_lib_facilities.h, which you're supposed to include in your programs. It likely contains the functions you're missing.
IIRC, he provides a file named something along the lines of std_lib_facilities.h, which you're supposed to include in your programs. It likely contains the functions you're missing.


Thanks Athar, but I couldn't get std_lib_facilities.h to work. I copied this header from his website and put it in the same folder, but my compiler gives this error:

This file includes at least one deprecated or antiquated header which \
may be removed without further notice at a future date. Please use a \
non-deprecated interface with equivalent functionality instead. For a \
listing of replacement headers and interfaces, consult the file \
backward_warning.h. To disable this warning use -Wno-deprecated.
This is a warning, not an error.

To disable it, you just need to do this:
To disable this warning use -Wno-deprecated


Just curious, what is the contents of std_lib_facilities.h ???
Last edited on
Just curious, what is the contents of std_lib_facilities.h ???


see this link: http://www.stroustrup.com/Programming/std_lib_facilities.h
Topic archived. No new replies allowed.