#Should I try to completely understand everything about C before moving on to newer languages ike C++
128 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
there is a lot of stuff I still don't know about it
it's fine
It is?
I don't know every time I ask a question here I find out about 10 more things
when I passed my linear algebra lesson for the first time, I didn't rank quite well (a poor 14/20). the affine geometry lesson next semester, was entirely based on that one class. I studied for that exam, and presented that one and the linear algebra one again, to increase my score (without studying, because the teacher was nice: he kept the best score for students that represented in June, as a favour. since I had many other exams, I just didn't study and tried anyway). I got 18 and 19, respectively.
you might review C concepts while learning C++, get haha-moments, and understand better anyway
there are different theories, but often people tend ot agree that good programmers are programmers that know different languages on surface (because it shows they came accoss different paradigms and ideas), and are able to dig deep into one when required (because they understood the concepts). knowing all C by heart, doesn't sound like a requirement right now
Hmm...Oke I'll stick with C only for a bit just to really understand what I learned and then Move on to C++ since there is a big gap before we start it anyways
Oh I think I at least understand the concepts of it
that's already nice
Oke then I think I'll be moving on to C++ after a bit then
Thanks a lot for the help man
I hope sincerely that you are eased into C++ and not dropped straight into the deep end. Modern C++ scares even me with all the templating and whatnot.
don't forget to come back! 😉 life's better here
(it's a joke 😄 well, I mean it, but do what you prefer 😄 hahaha)
I know that there will be things you will immediately love and you may even start criticizing C somewhat.
A very simple example of that being function overloading.
Yee my prof is good since it was my first time programming and I Aced my mids due to his help...just hope it continues on to C++
Yee I just hope it's not that hard😭
Oh wait is that where you couldn't have 2 main functions of same name?
I would say it is a good idea to learn C++ and since you already know some C it won't be as difficult as a newcomer to the languages.
void foo(int arg);
void foo(float arg);
int main()
{
int i = 5;
float f = 5.0;
foo(i); // calls the int version
foo(f); // calls the float version
}
functions of the same name with different parameters
also I don't think you can overload the main function
No, even in C++ you cannot overload main().
templates are one of the main things that make me want to stay writing C++ over C
Going from naught to C++23 will scare most.
I hope that you start off aiming for C++03 or perhaps C++11.
The STL is also amazing compared to not having it at all
I would say C++14 since it kind of "fixes" some of the missing things in 11
But yeah totally agree C++23 is massive
Wait it has numbers? I'm Assuming you start from 01
Those numbers are the years that the then new standard came out.
C++03 came out in 2003.
Ohhh
This site has been most valuable to me. It may help you.
https://github.com/AnthonyCalandra/modern-cpp-features
Damn 23? It's still getting updates?
Just for reference, this site will be very helpful https://en.cppreference.com/w/
Not a tutorial site though
C is also still getting updates
There's C23 (or C2X I don't remember)
cppref has already started mentioning C++26 I noticed the other day.
I'll have it saved thanks alot
is there a calendar for C features?
Like a roadmap?
yeah, as it seems to be a roadmap
@bright mulch Have you used coroutines in any code yet?
Are they significant? I thought most of the functions we used were from C99
I personally haven't - but I really never see a good time to utilize it (and also am still new/learning it)
not really
the site I mentioned also has information on C too
Nope.
I work mostly in embedded these days.
Those compilers fall way, way back on standards. Always have.
Maybe if one used the GNU compilers, then you could use modern C++.
As it is, I am (still) tied to C++17.
Yee I see some are mentioned (C11)
Hey that's not too bad! At least you're not on C++11 - not saying I am but that would not be great
Yeah there's also a link for C23
There is also a C26 wat does that mean?
If true, it seems that 2026 is a unique year in that it brings out new standards for both C and C++.
I think they are supporting reflection in C++26
Mb I accidentally said C26 instead
if so that should be interesting
To be honest, even though C++26 has been announced, its contents will be quite fluid.
Some stuff may not be ratified.
Other stuff may be brought into the mix.
A roadmap for C++26 would be largely a work of fiction.
Man I can't wait to just jump into C++ now after my finals
Yeah, should be a lot of fun
For sure, a lot of what's listed is definitely not going to be delivered
Yee I hope so
im thinking
Also like the idea of std::hive
i went into C++ before i knew the basics of C and genuinely
That one is intriguing
i still think C is harder 💀
i literally went down the ladder instead of up (C#->C++->C) and ngl C just makes it way harder to do anythin
yeah there are less abstractions which make it seem harder
ie no inheritance without some kind of fuckery
C strings are pretty sad compared to C++ strings
on god
i still dont know how to read anything of any size from a stream
is that even possible
with a C string
CStrings and CPPStrings are different? 
fgets(buf, 1024, stdin);
``` in example i dont know how to make that 1024 entirely variable
yeah char * cstr;
std::string cppstr;
I think you mean string utils, If not, I suppose cppstrings keep the null terminator rule
Yeah
But, with C you are in complete control, so this is why it is so popular with embedded.
For instance, using the STL you think arrays (is: vector) just became 100x easier.
But if you let it, STL will use heap for anything dynamic.
That's the stuff of nightmares in embedded.
So then you need to learn allocators to ensure that you control dynamic allocations.
And suddenly something as simple as arrays isn't so simple after all.
I had to do this in a pacman project, but I don't remember the details
how do you do dynamic arryas without heap
allocators.
you can allocate scalable memory within the stack?
also isnt fam and vla technically just heap under the hood too or am i stupid
no idea, I stay away from VLAs
same
why?
Example:
In threadx, you can create byte pools.
You can do new and placement new, and redirect from heap to these byte pools.
These byte pools could be a stack buffer.
Or an area in the .bss.
A Variable Length Array (VLA) is an array where the size is not constant and depends on a variable.
int size = rand();
int vla[size]; // VLA of type int[size]
int not_vla[10]; // regular array of type int[10]
constexpr int size = 10;
int arr[size]; // also not a VLA, of type int[10]
VLAs have poor compiler support and can lead to unsafe code. The core issue with VLAs is that the compiler doesn't know the size of the stack frame. Without warning flags like -Wvla, it can be easy to create a VLA by accident, even in C++ with some compilers.
:white_check_mark: available since C99
:no_entry: not available in C++ at all
:no_entry: was never supported by MSVC
:warning: optional feature since C11
:warning: supported as non-standard extension by GCC, clang
VLA to allocate memory is a really bad idea
;compile -Wvla -std=c23
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
constexpr int sqr(int x) {
return x * x;
}
int main(void) {
srand(time(NULL));
int i = rand() % 30;
int arr[sqr(i)];
printf("%zu", sizeof arr / sizeof i);
}```
<source>:5:1: error: 'constexpr' requires an initialized data declaration
5 | constexpr int sqr(int x) {
| ^~~~~~~~~
<source>: In function 'main':
<source>:13:11: error: implicit declaration of function 'sqr' [-Wimplicit-function-declaration]
13 | int arr[sqr(i)];
| ^~~
<source>:13:3: warning: ISO C90 forbids variable length array 'arr' [-Wvla]
13 | int arr[sqr(i)];
| ^~~
Build failed
VLA to implify size computation, is a good idea
ah, so It is generally a bad idea to define an array's width with a non-constant integer expression
so tha'ts not vla?
int x, y; // assume given at runtime
double m[x][y]; // bad vla usage
double (*m)[x][y] = malloc(sizeof(*m)); // friendly vla usage
shouldn't be as sqr returns a constant signed integer expression
Also do you have to cast malloc there or is it not necessary
why would you need to cast malloc
You wouldn't even be doing malloc() in C++.
Since it of type void*
no it's fine
ok
ah wait, we are in C++ ?
No, but the question is about C++ after C.
new 
aaaaah
Still a good point (vla), though.
Plus OP would have learned about new vs malloc pretty damn early on anyway.
Also I believe it's necessary to cast there in C++
nobody mallocs in c++ 
but yeah, who needs malloc
@hidden tusk Has your question been resolved? If so, type !solved :)
!solved
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity