Path: utzoo!utgpu!news-server.csri.toronto.edu!dgp.toronto.edu!flaps Newsgroups: comp.lang.c From: flaps@dgp.toronto.edu (Alan J Rosenthal) Subject: Re: Functions returning Error codes or actual info Message-ID: <1990Sep11.121531.23065@jarvis.csri.toronto.edu> References: <772@babcock.cerc.wvu.wvnet.edu> Date: 11 Sep 90 16:15:31 GMT Lines: 19 vrm@cathedral.cerc.wvu.wvnet.edu (Vasile R. Montan) writes: > I am making a set of functions which return different types of >values: strings, integers, doubles, etc. For example: > char *get_string(); >However, I would also like the function to return an error code if the >function fails. I cannot just return a NULL pointer because I want >the function to be the same as all of the other get_xxx's. A method you didn't mention is to return a null pointer, and have a #defined constant for this. If you return some kind of distinguished value already for the integer functions, such as -1, you may want to have: #define INTERROR (-1) in your .h file. So put: #define STRINGERROR ((char *)0) in your .h file as well.