473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

what is the default return type of a function?

lgn
int or char or void? and how to check it?
thx!
Nov 13 '05 #1
4 9643
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
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Murat Tasan | last post by:
so i have a situation that i know cannot be solved directly, and i've already worked around it, but i was hoping to find an explanation as to why this behavior is as it is... i have an abstract...
4
by: aling | last post by:
What's the rule of default argument of function in C++? I found that the default argument of function could not necessary be a constant value. Is it true? Previously I thought that the default...
2
by: lgn | last post by:
int or char or void? and how to check it? thx!
10
by: geoffblanduk_nospam | last post by:
Just curious, we no longer require void on a method that takes no parameters; void methodWithNoParameters(void) has been replaced by void methodWithNoParameters(). Is there a good reason we...
4
by: breathwell | last post by:
Consider a C# function that logs an error string and returns a new Exception object: System.Exception LogError(string msg) { ... return new Exception(msg); }
31
by: CeZaR | last post by:
Hi, How can i specify the return type of a function returning a managed array of chars. If i try to write: "char __gc func()" i get an error! How can i do that? Thanks!
5
by: Harold Hsu | last post by:
Hi all, What's the default access type of a property declared in an interface? The one I'm looking at is IBindingList: Public Interface IBindingList .... ReadOnly Property AllowEdit As...
5
by: PsiX | last post by:
Hi, does the return type specifier const for functions for built-in types ever make sense? Like in: const void DoSth(); const int DoSth();
18
by: Carl Forsman | last post by:
there are 2 ways to return a value from a function ==================== 1) passing a reference as parameter - the following will return time void Table::Get(char* FieldName, *SYSTEMTIME time) {...
4
by: Sivakoti | last post by:
What is return type?how can we use it?
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.