473,395 Members | 1,937 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,395 software developers and data experts.

valid main declaration

Is the following valid in c++ ?

void main(void)
{

}

Sep 16 '05 #1
6 1726
Pep
ju**********@yahoo.co.in wrote:
Is the following valid in c++ ?

void main(void)
{

}


Why don't you compile it and see?

Sep 16 '05 #2

Pep wrote:
ju**********@yahoo.co.in wrote:
Is the following valid in c++ ?

void main(void)
{

}


Why don't you compile it and see?


I don't have a c++ compiler.

Sep 16 '05 #3
ju**********@yahoo.co.in wrote:
Is the following valid in c++ ?

void main(void)
{

}


No: the return type of main is int.
Best

Kai-Uwe Bux
Sep 16 '05 #4
* Pep:
ju**********@yahoo.co.in wrote:
Is the following valid in c++ ?

void main(void)
{

}


Why don't you compile it and see?


The result of that approach depends on the compiler, although some compilers,
such as <url: http://www.comeaucomputing.com/tryitout/>, are fairly reliable
guides to what the standard is.

'void main' is not valid C++, and not valid C, and never has been.

The OP should check this group's FAQ, and also Bjarne Stroustrup's C++ FAQ.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Sep 16 '05 #5

<ju**********@yahoo.co.in> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
| Is the following valid in c++ ?
|
| void main(void)
| {
|
| }
|

check here...

http://www.parashift.com/c++-faq-lite/newbie.html
Sep 16 '05 #6
Pep wrote:
Why don't you compile it and see?


There are compilers which take a "creative license" from the standards when
compiling code. Because of that, some compilers compile code which isn't
standard compliant and should be broken to begin with. Therefore, the test
you suggested isn't the best way if a piece of code is valid or not.
Best regards
Rui Maciel
--
Running Kubuntu 5.04 with KDE 3.4.2 and proud of it.
jabber:ru********@jabber.org
Sep 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris Croughton | last post by:
Does a translation unit have to have at least one externally visible declaration or function definition to be valid? As I read the standard, it doesn't: it must have at least one declaration or...
2
by: Jonathan Pryor | last post by:
I'm in need of a sanity check: is the following code valid C++? namespace foo { class NamespaceClass { }; } using namespace foo; class Bug_GlobalFriendDeclaresNamespaceClass {
21
by: Kannan | last post by:
Its been a while I have done pure C programming (I was coding in C++). Is the following function valid according to standard C? int main(int argc, char *argv) { int x; x = 9; printf("Value...
10
by: Raman | last post by:
Hi All, Is it valid: struct test{ }; I mean, Can we have a struct containing no members? Is this a an
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.