f



program that compiles in C compiler but not in C++ compiler

Hi,

I need a small program that compiles in C compiler but not in C++
compiler.

Thx in advans,
Karthik Balaguru

0
10/11/2006 3:59:42 PM
comp.programming 11491 articles. 2 followers. Post Follow

8 Replies
2581 Views

Similar Articles

[PageSpeed] 13

KBG <karthik.balaguru@lntinfotech.com> wrote:
> I need a small program that compiles in C compiler but not in C++
> compiler.

No problem, just send $10 to paypal@zevv.nl and I'll do your homework
for you.


-- 
:wq
^X^Cy^K^X^C^C^C^C
0
usenet3433 (123)
10/11/2006 4:03:28 PM
KBG said:

> Hi,
> 
> I need a small program that compiles in C compiler but not in C++
> compiler.

Can you think of any syntactic differences between C and C++? For example, 
what about keywords? They are very, very sensitive to syntax. Worth 
thinking about.

-- 
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
0
invalid171 (7008)
10/11/2006 4:09:33 PM
KBG wrote:

> I need a small program that compiles in C compiler but not in C++
> compiler.

Have a look at:

   http://david.tribble.com/text/cdiffs.htm

-- 
mail1dotstofanetdotdk
0
breese (255)
10/11/2006 4:16:36 PM
KBG wrote:
> Hi,
>
> I need a small program that compiles in C compiler but not in C++
> compiler.
>

For sufficiently recent definitions of "C compiler, the following does
the trick, but if this is a homework question it's probably not the
answer you want.

#include <stdio.h>

int main(void)
{
    char * restrict hi = "Hello, world\n";
    printf("%s", hi);
    return 0;
}

0
sjdevnull (405)
10/11/2006 9:15:50 PM
Hi,

Loooks interesting. Need to give these and the links a try this weekend
:):) 

Thx,
Karthik Balaguru

0
10/13/2006 8:37:12 AM

-- 
www.personal.leeds.ac.uk/~bgy1mm
freeware games to download.

"KBG" <karthik.balaguru@lntinfotech.com> wrote in message 
news:1160582382.676563.143370@b28g2000cwb.googlegroups.com...
> Hi,
>
> I need a small program that compiles in C compiler but not in C++
> compiler.
>
> Thx in advans,
> Karthik Balaguru
>
The way to to this is to put a
#ifdef __cplusplus
#error this program must be compiled under C
#endif

in your code.
That way it is obvious that the program is non-cplusplusable, deliberately. 


0
regniztar (3128)
10/14/2006 7:49:19 AM
"Malcolm" <regniztar@btinternet.com> writes:

>>
>> I need a small program that compiles in C compiler but not in C++
>> compiler.
int main(void) {
  int this = 10;
  return 0;
}

very easy. 

-- 
Please remove just-for-news- to reply via e-mail.
0
10/14/2006 8:13:34 AM
KBG wrote:
> 
> Loooks interesting. Need to give these and the links a try this
> weekend :):)

What looks interesting?  Usenet articles need to stand by
themselves, that is what quotes are for.  Google is not Usenet, it
is only an execrebly poor interface to the system.  See my sig and
the links in it below.

-- 
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on 
 "show options" at the top of the article, then click on the 
 "Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>


0
cbfalconer (19194)
10/14/2006 11:39:07 PM
Reply: