Jump to content
  • Advertisement
Sign in to follow this  
Myotis

Visual Express 2005

This topic is 4440 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am using Microsoft Visual C++ 2005 Express Edition Visual C++ EE and would like to know how to create C files with it. All I see when creating a new project/source code is a C++ file. I have tried entering a C code in it and it worked but the editor does not highlight the keywords of C ( scanf, prinft etc...) . Is writing C code in C++ files the way to go ? Is there a way to highlight the C commands ? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
scanf, printf, etc. are not keywords, they are functions. Just as 'cout' isn't highlighted in C++. Keywords are like 'struct', and 'float'.

Share this post


Link to post
Share on other sites
I don't think scanf, or printf would show up as keywords to begin with. They are function names and therefore are not highlighted. For instance I know in C++ cout isn't highlighted in the editor.

As for writing C code in C++ files: The only difference is the file extensions and, in the end, file extensions mean nothing when programming they are only used to tell the OS how to handle a particular file.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ezbez
scanf, printf, etc. are not keywords, they are functions. Just as 'cout' isn't highlighted in C++. Keywords are like 'struct', and 'float'.


Ah! Thanks. So a C++ compiler is just as good for C.

Share this post


Link to post
Share on other sites
according to the documentation,

Give your files the .c extension, for example mysource.c. The Visual C++ compiler automatically assumes that files with the .C extension are C files and not C++ files, and rejects C++ syntax and keywords (such as public, private, and class).



http://www.daniweb.com/techtalkforums/thread16256.html
this talks about setting it to "Compile as C" I think i have done the same before, now I just can't find it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Myotis
Quote:
Original post by Ezbez
scanf, printf, etc. are not keywords, they are functions. Just as 'cout' isn't highlighted in C++. Keywords are like 'struct', and 'float'.


Ah! Thanks. So a C++ compiler is just as good for C.

Not really, no. A C++ compiler is only good for C++. The major alternatives happen to come with both, but in general a C++ compiler will only compile that subset of valid C code that happens to be valid C++ code as well.

Using VS, I believe giving the source a .c extension instead of a .cpp one will result in C compilation. If not, the neccessary compiler switch is /TC.

CM

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!