Starting C with knowledge of C++

Hey guys, I've posted a little bit on these forums and gained some valuable knowledge of C++ thanks to some very helpful people here. I'm still a beginner really, but my understanding of certain C++ concepts has improved a lot thanks to them.

This isn't strictly to do with C++, but what I would like to ask is whether or not it would be difficult to transition from C++ to C, with an understanding of concepts such as variables, i/o, conditionals, loops and functions?

I ask this because I will be starting my studies on a Computer Science course soon and have found out that the language we will be using is C.

Semantically and syntactically, is C similar to C++? C++ is my only language so that could be an issue.

Any advice is appreciated.
It's.. different, they may opt for minimalistic, single purpose apps. You're probably aware it's not object orientated and that you have to declare "all variables" up the top of a code block preceding any statements. There's a lot of other subtle differences.
Yeah, C++ is very similar to C. It was even built on it(influenced by C).

Aceix.
Microsoft compilers are two standards behind in C - they support C90 while there has been C99 and C11. In C99 and beyond you do not have the restriction of declaring all variables at the beginning of a code block.

Fun fact: the const keyword was brought into C from C++
Semantically and syntactically, is C similar to C++?


Remove:
- classes
- templates
- operator overloading
- function overloading
- namespaces

... and you have 95+% of the difference between the two ironed out.
Last edited on
Coming from someone who codes in a mix of C and C++ now adays, I can give a heads up.

The transition was mostly painless. Tools like valgrind and gdb become easier to use, errors are more obvious (no 150 line errors), etc.

However, I still use certain C++ libraries, specifically ASIO and cppformat. They are super powerful in both optimization and feature, while being incredibly easy to use. Doing something similar in C is damn near impossible without sacrificing usability.

I'd find the most enjoyable thing about using C is the simplified symbol mangling. Most compilers are as simple as prepending a "_" to the function name or variable. Note that there is no standard however. So things like fastcall (which is a bad example since gcc *does* actually support fastcall) can break interoperability between GCC and VC++.

Even given that situation, compared to C++ where ABI breaks between almost every single compiler I know of (aside from maybe gcc and clang) and even between different compiler versions, the simplification is bliss when it comes to linking and dynamically loading libraries (which you can't even do in C++ since there isn't a way to specify what symbol you want).
Last edited on
Even given that situation, compared to C++ where ABI breaks between almost every single compiler I know of (aside from maybe gcc and clang) and even between different compiler versions, the simplification is bliss when it comes to linking and dynamically loading libraries (which you can't even do in C++ since there isn't a way to specify what symbol you want).


This is the single greatest flaw with C++, and it seems that no one is addressing it.
C++ Modules are the first step to addressing it, but they keep getting pushed to the next standard. They've been around since before C++11.
Last edited on
Thanks for all the informative replies guys. Even though this is a C++ website, is help given with C questions as well?
Not so much, I don't even know the right place to put it. As long as you specify it's for C and not C++, you might get help instead of people asking you why you're using C.
Okay, thank you.
Topic archived. No new replies allowed.