PDA

View Full Version : Simple (stupid) questions - no programming



jvu
02-04-2009, 02:13 AM
Forgive me, I am a newb. Currently taking a Intro to C Programming class. I just received Visual Studio 2008. To program C, do I choose C++ (other options being C# and Visual Basic) as one of the options to write and build my code in? Also, what is the difference between a .h (header) and regular .c file? Is it just where you put all your variables and such?

Adak
02-04-2009, 02:40 AM
You want to choose C++, but save your file with just a .c instead of .cpp, file extension.

I'm waiting for some joker to tell you "choose Visual Basic!" :)

The best way to understand what a header file is, is to look at them with Notepad or any plain text editor. Don't change them in any way, of course, but nothings better than seeing just what they really have in them, for yourself.

Salem
02-04-2009, 11:16 AM
Except most standard header files contain a lot of "necessary evil", and are not that good to learn from.

Sentral
02-04-2009, 02:13 PM
A header (.h) file is basically where you put your declarations and prototypes. While the .c file is mainly for the implementation of the stuff you put in the header. It's mainly for organization, so don't worry too much about it.

sean
02-04-2009, 02:30 PM
A header (.h) file is like the list of words in a phone that uses predictive text - it just says, "these are possible words" - it doesn't actually define them, it just says that they exist and people can use them. A .c file is like the dictionary - all the possible words are defined and detailed.

happyclown
02-04-2009, 06:11 PM
If you have any problems with Visual C++, feel free to post here. [EDIT: post in the Tech Forum]

I've been using it for about 2 weeks now, so I've already encountered problems that you will no doubt run into.

It's a great program, but it can be scary for a newbie. :)

swgh
02-06-2009, 06:47 PM
Also be prepared for an onslaught of MS own warnings on C functions such as scanf, strcpy, fprint etc.. you can define a macro to get rid of them, im sure Cornedbee was kind enough to explain this in quite an old thread.

To be perfectly honest, MSVC is a bit of an overkill for C, id use code::blocks or at a push WigexDevC++ and change the extention to .c ;)

Elysia
02-07-2009, 04:54 AM
Also be prepared for an onslaught of MS own warnings on C functions such as scanf, strcpy, fprint etc.. you can define a macro to get rid of them, im sure Cornedbee was kind enough to explain this in quite an old thread.

*shrug* They are only trying to look out for your own well being and to help you find and debug errors, so I say they are perfectly justified.

CornedBee
02-07-2009, 05:04 AM
SafeCRT is to Visual C++ what UAC is to Vista - a well-meant effort, but a horrible execution.

Elysia
02-07-2009, 05:06 AM
We obviously love to disagree, but the thing is that they are easy to get rid of with wrappers and macros.
Anyway, these are the two sides of the argument. Anyone is free to choose their own approach.

rags_to_riches
02-07-2009, 08:53 AM
Also be prepared for an onslaught of MS own warnings on C functions such as scanf, strcpy, fprint etc.. you can define a macro to get rid of them, im sure Cornedbee was kind enough to explain this in quite an old thread.

Or add

#pragma warning(disable: 4996)
to the start of the file.

Elysia
02-07-2009, 08:55 AM
No, bad. It disables all deprecated warnings. Including those not for using the safe versions of the CRT.
There is a define that you should use.

VirtualAce
02-07-2009, 11:40 AM
_CRT_SECURE_NO_DEPRECATE
Put that in the pre-processor section of the project settings.

foxman
02-07-2009, 04:44 PM
I'll add, for more info on Visual Studio, go look on MSDN: http://msdn.microsoft.com/en-ca/library/52f3sw5c.aspx.

You'll find all the answer to your questions there.