How can I just write C code with MS Visual C++

This is a discussion on How can I just write C code with MS Visual C++ within the C++ Programming forums, part of the General Programming Boards category; Is this possible? I'm new to programming, and would like to learn C, before I start learning about objects etc. ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    31

    How can I just write C code with MS Visual C++

    Is this possible?

    I'm new to programming, and would like to learn C, before I start learning about objects etc.

    What is the simplest way to start write in C programs?

    Thanks for your help!

    Dan

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    C++ is kind of like a superset of C. There are cases in which something that is completely valid in C will not compile as C++, and with the advent of namespaces and a change in the conventions for the standard libraries there are many exceptions, but here are some suggestions:

    - Just learn C++. You learn most of C along the way anyway.
    - Write C code, and then just make the necessary changes to the header files to make it C++ compileable.
    - Get a different compiler. The free Dev-C++ from bloodshed.net will let you compile programs as C. MS VC++ might allow you too as well, I've never used it, so check that first. I would've assumed it would.

  3. #3
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    I believe Visual C++ has an option somewhere that allows you to compile the code as C.

    Also, I think if your source file has a .C extension, it treats it as C code automatically.

  4. #4
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    Quote Originally Posted by sean_mackrory
    C++ is kind of like a superset of C. There are cases in which something that is completely valid in C will not compile as C++, and with the advent of namespaces and a change in the conventions for the standard libraries there are many exceptions, but here are some suggestions:

    - Just learn C++. You learn most of C along the way anyway.
    - Write C code, and then just make the necessary changes to the header files to make it C++ compileable.
    - Get a different compiler. The free Dev-C++ from bloodshed.net will let you compile programs as C. MS VC++ might allow you too as well, I've never used it, so check that first. I would've assumed it would.
    To the OP, take this "advice" with a grain of salt. If you want to learn C first, go right ahead. Nothing wrong with that at all.

    To sean: the simple solution to his question is to create files with a .c extension, as Dante said. VC++ automatically creates them with a .cpp extension if no other is specified. Also, please do not recommend one IDE/compiler over the other if you have never even used one of them. Stupid thing to do.

    Microsoft's VC++ line of compilers are fine.
    Last edited by spoon_; 07-02-2005 at 02:52 PM.
    {RTFM, KISS}

  5. #5
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Also, please do not recommend one IDE/compiler over the other if you have never even used one of them. Stupid thing to do.
    Did I recommend one over the other? No, I told him that if VC++ did not do it, Dev-C++ would, but that he needed to check on it first. And I cannot find one sentence in which I said there was anything wrong with learning C first. I merely suggested he might not want to bother if he plans to learn C++ eventually anyway. Don't bring your bad mood onto the board. Stupid thing to do.

    And you'll notice that when I said, "I would've assumed it would", my advice is not really dripping with anti-Microsoft disdain, so don't get so defensive. They were "suggestions" for him to look at anyway.

  6. #6
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    Quote Originally Posted by sean_mackrory
    - Get a different compiler. The free Dev-C++ from bloodshed.net will let you compile programs as C. MS VC++ might allow you too as well, I've never used it, so check that first. I would've assumed it would.
    Get a different compiler? Based on what facts?

    gg
    {RTFM, KISS}

  7. #7
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    FACT: Dev-C++ can compile C code
    FACT: He wasn't aware of how to compile C code

    MY THOUGHT: If it he can find no way of compiling C code in VC++, he may want to check out Dev-C++.

  8. #8
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    Quote Originally Posted by sean_mackrory
    FACT: Dev-C++ can compile C code
    FACT: He wasn't aware of how to compile C code

    MY THOUGHT: If it he can find no way of compiling C code in VC++, he may want to check out Dev-C++.
    FACT: You've never used VC++

    FACT: Recommending one product over another (which you've never used) is......... r e t a r d e d.
    {RTFM, KISS}

  9. #9
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Show me where I "recommended" Dev-C++ over VC++. I suggested he try a different compiler, sure, but is it not retarted to ignore the fact that I told him to research VC++'s ability to do so before switching, stating clearly that I would be surprised if it didn't.

  10. #10
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    Quote Originally Posted by sean_mackrory
    Show me where I "recommended" Dev-C++ over VC++. I suggested he try a different compiler, sure, but is it not retarted to ignore the fact that I told him to research VC++'s ability to do so before switching, stating clearly that I would be surprised if it didn't.
    Apparently, he has a compiler. He does not need to get another one. He had one simple question that you are not qualified to answer.

    So, given that, SUGGESTING a different compiler in this circumstance is r e t a r d e d.
    {RTFM, KISS}

  11. #11
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    He does not need to get another one.
    If VC++ does not allow you to compile C code, then he DOES need another compiler. Again, I clearly stated that I would've thought that VC++ would compile C code, and that he would still need to confirm this. Dante did that.

    At that point, you brought your bad day on the board and decided to argue with my advice, clearly labelled as "suggestions".

    I am closing this thread because it's going nowhere. If the original poster has any further questions or anyone has constructive advice to give, please PM me or another mod who is online and it can be reopened for you. If spoon_ has more problems, he can pm me too.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. Erros in Utility Header File
    By silk.odyssey in forum C++ Programming
    Replies: 4
    Last Post: 12-22-2003, 05:17 AM
  4. Using 'if' with char arrays or string objects
    By c++_n00b in forum C++ Programming
    Replies: 36
    Last Post: 06-06-2002, 09:04 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21