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

Started by
8 comments, last by leafsfan16 22 years, 8 months ago
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?
Advertisement
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."



-Forcaswriteln("Does this actually work?");
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.
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
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
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!]
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
Learn assembly too.
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
C++ is an extension to C. If you fully know C++, then you most likely fully know C.
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.
And Unless Microsoft has changed any oftheir happy little games, your stuck with it.Patrick Nortin ~TechTV''s "The ScreenSavers"~

This topic is closed to new replies.

Advertisement