Archived

This topic is now archived and is closed to further replies.

Should I learn C if i already know C++?

This topic is 5965 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

I am currently learning C++. I''m thinkin ahead and I eventually want to go into windows game programming with DirectX. Should I learn C to go into windows game programming or will C++ be sufficient for windows game programming in DirectX?

Share this post


Link to post
Share on other sites
C++ is great for Windows programming. You''ll probably learn most of the C syntax by looking at C-users'' code.

-Forcas


"Elvis is alive. He is Barney the purple dinosaur. He is the pied piper that leads our children into the wages of sin and eternal damnation."



Share this post


Link to post
Share on other sites
Uh... if you know C++ you already know C. Just don''t use classes, templates, (or any other C++ specific additions, like new and delete for example) and use the ANSI C compilant functions.

Share this post


Link to post
Share on other sites
C++ is sufficent for Windows game programming, but learning C can only help you. You can mix C & C++ code very easily, and existing code may be written in C. The rules are different in C than C++, so knowing them is important. There are a few chunks of code that will compile in C and C++, but do different things.

i.e.

float f = 3.1415f;
int i;
i = f;


Magmai Kai Holmlor
- Not For Rent

Share this post


Link to post
Share on other sites
Turning C++ into C. Move all the variables to the beginning of the functions they''re in. Change all references to pointers (that are dereferenced before use). Use stdio, stdlib, and other standard C libraries instead of their C++ counterpart (you could already be using these in C++, there''s nothing stopping you). Change all classes to typedef''ed structs, use vtables instead of virtual functions, and change member functions (and constructors/destructors) to functions that accept a pointer to the struct as the first argument (that''s the easiest way, but not the only one). Change all templates to multiple functions or callback functions. Change all inline functions to macros (this will change in the future, C is going to get inline functions, but most compilers haven''t updated to do this yet). Change all constants to defines (macros). Put void instead of nothing as the only parameter of functions that receive no parameters. Use void pointers instead of base class pointers, and have the "common variables" in that struct moved to the top, so that you can cast it as the base class and use it.

Hmm, I think that''s all (it really is a lot simpler than it looks to use C, my list isn''t really that long ).

[Resist Windows XP''s Invasive Production Activation Technology!]

Share this post


Link to post
Share on other sites
I say go for it. Learn C. I learned C++ first, so everytime I look at strict C code, it kinda looks foreign to me (what, no classes?!?). It''s a whole paradigm shift.

Jinushaun

Share this post


Link to post
Share on other sites
The answer is NO if your planning to spend money or to take a class to learn it. You will pick up C as you progress with C++. There will be times when you happen upon others C code and you will be able to understand it fairly easily and will just eventually learn the language that way. There is very little difference between C and non-object oriented C++.

Possibility

Share this post


Link to post
Share on other sites
I don''t see a reason to sit down and "learn" C per se, but a knowlege would be helpful. It''s not completely dead, the game-specific code (it used Quake3) for Star Trek Voyager: Elite Force was all in C.

Share this post


Link to post
Share on other sites