need

Discussion in 'C++' started by Raj, Sep 9, 2009.

  1. Raj

    Raj Guest

    tell me one program that works on c but not on c++?
    Raj, Sep 9, 2009
    #1
    1. Advertising

  2. Raj

    Wolfnoliir Guest

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


    A module for the Linux kernel maybe.
    Wolfnoliir, Sep 9, 2009
    #2
    1. Advertising

  3. -----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)

    iEYEARECAAYFAkqnuE0ACgkQG6NzcAXitM9NMQCcCxKD3a3FUo9lcdjPXor1nnnO
    OOIAn113NrCKcB4yK8YHlAhJD26pRKgv
    =Ls3l
    -----END PGP SIGNATURE-----
    Michael Tsang, Sep 9, 2009
    #3
  4. Raj

    Pep Guest

    On Sep 9, 3:01 pm, Wolfnoliir <> 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
    Pep, Sep 9, 2009
    #4
  5. Pep wrote:
    > On Sep 9, 3:01 pm, Wolfnoliir <> 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
    Victor Bazarov, Sep 9, 2009
    #5
  6. Raj

    Default User Guest

    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
    Default User, Sep 9, 2009
    #6
  7. Raj

    Ian Collins Guest

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


    Whatever happened to please?

    --
    Ian Collins
    Ian Collins, Sep 9, 2009
    #7
  8. Raj

    Paul N Guest

    On 9 Sep, 14:57, Raj <> 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.
    Paul N, Sep 9, 2009
    #8
  9. Don't forget sizeof('x'). It's sizeof(int) or sizeof(char), depending
    on if it's compiled as C or C++.
    Joshua Maurice, Sep 9, 2009
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TN Bella
    Replies:
    1
    Views:
    2,455
    Edward
    Jun 18, 2004
  2. Teep
    Replies:
    2
    Views:
    754
    Larry Marburger
    Jun 21, 2004
  3. John
    Replies:
    1
    Views:
    384
    John C. Bollinger
    Aug 19, 2004
  4. Replies:
    17
    Views:
    583
    osmium
    Oct 31, 2007
  5. Angus
    Replies:
    3
    Views:
    319
Loading...

Share This Page