Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > need

Reply
 
 
Raj
Guest
Posts: n/a
 
      09-09-2009
tell me one program that works on c but not on c++?
 
Reply With Quote
 
 
 
 
Wolfnoliir
Guest
Posts: n/a
 
      09-09-2009
Raj wrote:
> tell me one program that works on c but not on c++?


A module for the Linux kernel maybe.
 
Reply With Quote
 
 
 
 
Michael Tsang
Guest
Posts: n/a
 
      09-09-2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Raj wrote:

> tell me one program that works on c but not on c++?


main(){ /* implicit int declaration */
int new=0; /* reserved word in C++ */
printf("%d\n",new); /* implicit function declaration */
return 0;
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkqnuE0ACgkQG6NzcAXitM9NMQCcCxKD3a3FUo 9lcdjPXor1nnnO
OOIAn113NrCKcB4yK8YHlAhJD26pRKgv
=Ls3l
-----END PGP SIGNATURE-----

 
Reply With Quote
 
Pep
Guest
Posts: n/a
 
      09-09-2009
On Sep 9, 3:01*pm, Wolfnoliir <(E-Mail Removed)> wrote:
> Raj wrote:
> > tell me one program that works on c but not on c++?

>
> A module for the Linux kernel maybe.


main()
{
std::cout << "hello world" << std::endl;
}

The C++ std:: class does not exist in C
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      09-09-2009
Pep wrote:
> On Sep 9, 3:01 pm, Wolfnoliir <(E-Mail Removed)> wrote:
>> Raj wrote:
>>> tell me one program that works on c but not on c++?

>> A module for the Linux kernel maybe.

>
> main()
> {
> std::cout << "hello world" << std::endl;
> }
>
> The C++ std:: class does not exist in C


The OP asked for the other way around.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      09-09-2009
Michael Tsang wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Raj wrote:
>
> > tell me one program that works on c but not on c++?

>
> main(){ /* implicit int declaration */
> int new=0; /* reserved word in C++ */
> printf("%d\n",new); /* implicit function declaration */
> return 0;
> }


Implicit function declarations have been out of C since the release of
the 1999 standard. Even under c89, use of a variadic function without a
prototype in scope is undefined behavior.



Brian

--
Day 219 of the "no grouchy usenet posts" project
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      09-09-2009
Raj wrote:
> tell me one program that works on c but not on c++?


Whatever happened to please?

--
Ian Collins
 
Reply With Quote
 
Paul N
Guest
Posts: n/a
 
      09-09-2009
On 9 Sep, 14:57, Raj <(E-Mail Removed)> wrote:
> tell me one program that works on c but not on c++?


#include <stdlib.h>

int main(void) {
int *ptr = malloc(10);
return 0;
}


In C++ you need to cast the result from malloc, which is unnecessary
(and discouraged) in C.

Alternatively, as Michael Tsang pointed out, you could use an
identifier (such as "new") which is a keyword in C++.

Paul.
 
Reply With Quote
 
Joshua Maurice
Guest
Posts: n/a
 
      09-09-2009
Don't forget sizeof('x'). It's sizeof(int) or sizeof(char), depending
on if it's compiled as C or C++.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to "shred" hardive..need software. Xeno Chauvin Computer Support 4 03-13-2005 01:26 PM
Need help with need to Force Garbage Collect John Java 1 08-19-2004 03:32 PM
Need help! I need to add lead zeros to a textbox Teep ASP .Net 2 06-21-2004 01:04 PM
Please help!!! Need datagrid selection to fill textboxes...Need quick!! TN Bella ASP .Net 1 06-18-2004 01:31 AM
Need to compare Photos to DVD software - Need Help? Bob Digital Photography 4 02-04-2004 02:13 AM



Advertisments