The differences are listed here

http://www.geocities.com/karthika_79/diff.html

hope this helps,
karthika

Recommended Answers

All 9 Replies

Aside from being difficult to read against that background, an awful lot of that makes no sense, is innacurate or completely wrong.

return type of main and any function is defaulted to int.(0 if success and 1 if failure)

return types are never defaulted to anything. the standard specifies that main must return an int, however, it is not valid to simply write your function signature without explicitly specifying a return type.

Array elements that donot have initializers are assigned '0'.

That's not true for either C or C++. Array elements which are uninitialised remain uninitialised. To access an uninitialised variable or array element is undefined behaviour.

Aside from being difficult to read against that background, an awful lot of that makes no sense, is innacurate or completely wrong.
return types are never defaulted to anything. the standard specifies that main must return an int, however, it is not valid to simply write your function signature without explicitly specifying a return type.

That's not true for either C or C++. Array elements which are uninitialised remain uninitialised. To access an uninitialised variable or array element is undefined behaviour.

Please verify anything before you post.
1.Arrays that are static or global are initialized with zeros if no values are mentioned. You can check this out in http://www.cplusplus.com/doc/tutorial/arrays.html

2.Main and other functions default to int return type. ISO standard requires main to be return type int always.I accept. But my compiler and my friends compiler didnot complain when main was not specified with returntype int..though its not standard C++ programming, You can see tutorials and books still with code like
main()
{....
return 0;
}
For example (main): http://www.cs.uregina.ca/Dept/manuals/Manuals/7Language/7_18C++/c++.htm
(other functions) : http://jupiter.clarion.edu/~rsmaby/cis254/introcpp.html
http://cs.nmhu.edu/personal/curtis/cs1htmlfiles/essentialssec3.htm

Though you were not polite to ask me to check,I appreciate your valuable inputs. I understand what you meant.It was just an ambiguity which I now madeup by putting a Note there. Thanks a lot.

Please verify anything before you post.
1.Arrays that are static or global are initialized with zeros if no values are mentioned. You can check this out in http://www.cplusplus.com/doc/tutorial/arrays.html

Although it is true that static and global array are initalized with 0, you failed to mention that in the differences list. And since Bench assumed you were referring to local arrays, which are completely random, he was correct in saying that elements will remain unitialized until you put values into them.

And I wonder why that was. It was because YOU didn't specify that it's only global and static arrays, not him, and so your post is actually incorrect, unless you specifically state that it's only global and static members.

2.Main and other functions default to int return type. ISO standard requires main to be return type int always.I accept. But my compiler and my friends compiler didnot complain when main was not specified with returntype int..though its not standard C++ programming, You can see tutorials and books still with code like
main()
{....
return 0;
}
For example (main): http://www.cs.uregina.ca/Dept/manuals/Manuals/7Language/7_18C++/c++.htm
(other functions) : http://jupiter.clarion.edu/~rsmaby/cis254/introcpp.html
http://cs.nmhu.edu/personal/curtis/cs1htmlfiles/essentialssec3.htm

Though you were not polite to ask me to check,I appreciate your valuable inputs. I understand what you meant.It was just an ambiguity which I now madeup by putting a Note there. Thanks a lot.

It's still not correct to neglect a return type on main(), even if the compiler doesn't complain. For example, Visual C++ didn't (I'm not sure if it still does; I think so) complain about void main(). Does that mean it's correct? Of course not, it never has been, and probably never will be. So you can't always rely on compilers to be correct.

Check by YourSelf
The above is an elaborate explanation on incompatibilities..A good source of info.


This is ofcourse a good quick reference of differences for novices
http://www.geocities.com/karthika_79/diff.html

Your background makes it very hard to read, and it's highly unlikely any newbies will stop very long trying to make out the words that are barely visible against the low constrast.

2.Main and other functions default to int return type. ISO standard requires main to be return type int always.I accept. But my compiler and my friends compiler didnot complain when main was not specified with returntype int.

Just because something works on your compiler or your friend's compiler doesn't mean that it will work on other people's. Compilers are allowed to work in ways which aren't defined by the standard, such as allowing void main() - implementations which conform more strictly to the standard are well within their right to complain about this (And some do!).

If you intend your site to be used as a reference for beginners, then may I suggest that you make no assumptions about what compiler your visitors might be using. or whether or not they are compiling in a mode which adheres strictly to the standard.

Just because something works on your compiler or your friend's compiler doesn't mean that it will work on other people's. Compilers are allowed to work in ways which aren't defined by the standard, such as allowing void main() - implementations which conform more strictly to the standard are well within their right to complain about this (And some do!).

If you intend your site to be used as a reference for beginners, then may I suggest that you make no assumptions about what compiler your visitors might be using. or whether or not they are compiling in a mode which adheres strictly to the standard.

got it.no dependencies on compilers.I will put it as per standards alone.thanks.

Although it is true that static and global array are initalized with 0, you failed to mention that in the differences list. And since Bench assumed you were referring to local arrays, which are completely random, he was correct in saying that elements will remain unitialized until you put values into them.

It's still not correct to neglect a return type on main(), even if the compiler doesn't complain. For example, Visual C++ didn't (I'm not sure if it still does; I think so) complain about void main(). Does that mean it's correct? Of course not, it never has been, and probably never will be. So you can't always rely on compilers to be correct.


Your background makes it very hard to read, and it's highly unlikely any newbies will stop very long trying to make out the words that are barely visible against the low constrast.

I think you didnot check the link after Bench mentioned about the background.

I think you didnot check the link after Bench mentioned about the background.

I did read it, and am restating it to emphasize the point. My point was that if you have a hard-to-read background, it actually discourages newbies who are going to read your "quick reference". It also doesn't make your site look professional, like a site should be that will attract newbies.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.