By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,654 Members | 936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,654 IT Pros & Developers. It's quick & easy.

what is the default return type of a function?

P: n/a
lgn
int or char or void? and how to check it?
thx!
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
In article <bp***********@mail.cn99.com>, lgn wrote:
int or char or void? and how to check it?


You should always fully specify the return type of the functions
you write. In older standards, int was the default return type.
You check it by reading the standard document (not at my desk at
the moment so I can't quote it).
--
Andreas Kähäri
Nov 13 '05 #2

P: n/a
In <bp***********@mail.cn99.com> "lgn" <li*******@163.com> writes:
int or char or void? and how to check it?


By reading a C book.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #3

P: n/a
"Martin Ambuhl" <ma*****@earthlink.net> wrote in message
news:q5******************@newsread2.news.atl.earth link.net...
lgn wrote:
int or char or void? and how to check it?
thx!


Until 1999, a function without an explicit return type returned an int.
Since 1999, a function without an explicit return type is an error.


I think that's somewhat misleading. For the vast majority of C programmers,
implicit int is still a <cough>feature</cough> of our conforming compilers.
In other words, the C90 standard itself didn't change as a consequence of
C99. [Of course, sensible C programmers don't use implicit int without a
severe reason, e.g. gun to the head... :-)]

--
Peter
Nov 13 '05 #4

P: n/a
In <q5******************@newsread2.news.atl.earthlink .net> Martin Ambuhl <ma*****@earthlink.net> writes:
lgn wrote:
int or char or void? and how to check it?
thx!


Until 1999, a function without an explicit return type returned an int.
Since 1999, a function without an explicit return type is an error.


Compilers, however, haven't changed their behaviour on 1999-01-01.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.