Simple Sorcerer
if the course is really bad there will be bad reviews about it
Simple Sorcerer
When I started, I was looking for quick courses and then gradually gained experience. read Bjarne Stroustrup already for those who want to be a pro+++
Simple Sorcerer
I'll probably get a ban for advertising the creator's book? Truth Madhu ?
Simple Sorcerer
Tutorial for Russian / Ukraine: ravesli com I started with this. Very good course
Anonymous
Why can't users provide links to their training courses??? even if it’s an advertisement like “my course is the best.” in any case, the person tried and made these courses for those who want to learn C/C++
It is because we know that some courses are bad. People often claim that the course they did or the book they read are the best but the rest of the community know otherwise. The Resources section for this group (link to which is in the pinned post) compiles the best resources available for learning C/C++ as acknowledged by the wider C/C++ community. So just stick to those
Ludovic 'Archivist'
Why can't users provide links to their training courses??? even if it’s an advertisement like “my course is the best.” in any case, the person tried and made these courses for those who want to learn C/C++
One of the reasons for that is the fact that a lot of those "user recommendations" are fake. A good example of fake recommendations users are codingninjas which are just assholes giving shitty courses and selling them with thousands of fake reviews
Anonymous
I'll probably get a ban for advertising the creator's book? Truth Madhu ?
Creator's book? You mean Bjarne Stroustrup's books or K&R C
Anonymous
Tutorial for Russian / Ukraine: ravesli com I started with this. Very good course
I don't know Russian. But there are others here who can say if that is any good
Anonymous
I meant the creator
Creator of what?
Anonymous
Tutorial for Russian / Ukraine: ravesli com I started with this. Very good course
I just took a cursory look (not more than 2 minutes) at that site with English translation. It seems ok but I will let others like @unterumarmung confirm
Simple Sorcerer
I just took a cursory look (not more than 2 minutes) at that site with English translation. It seems ok but I will let others like @unterumarmung confirm
I’ll say right away that there is only a basic quick course that will help beginners quickly master basic C++
Danya🔥
I don't like it
Simple Sorcerer
It's transled learncpp AFAIK
I didn't even know
Anonymous
It's transled learncpp AFAIK
I took a look at noexcept section and ranges section. Looked like someone unlike Herbert Schildt or Yashwant kanitkar @simple_sorcerer you have ur answer
Danya🔥
Tutorial for Russian / Ukraine: ravesli com I started with this. Very good course
https://t.me/cpp20programming/184 Really good courses for Russian speaking learners are listed here at the end
Simple Sorcerer
Danya🔥
Are you sure that beginners are ready to watch videos for 1 hour+
If one is not ready, why even bother learning?
Simple Sorcerer
If one is not ready, why even bother learning?
Let's even take ourselves for example. You just started learning the language and want to feel it. I would probably watch a couple of videos and say that c/c++ Definitely not for me. You provided a link above tutorial learncpp. I think this is what those who want to start need
Simple Sorcerer
I'm not saying the lectures are bad. They are good, but personally I never liked sitting through lectures
mito
#cpp So, I have this code, main.cpp #include <iostream> #include <cstdint> #include <cassert> int main() { char *val = (char *)malloc(5); if (val == nullptr) { std::cout << "not ok\n"; return 1; } assert(val); return 0; } The assert() here is like a macro function which does static_cast to bool and does ternary condition or atleast based on what I have observed through linting by VSCode. From assert.h / <cassert>, #define assert(expr) (static_cast <bool> (expr) ? void (0) : __assert_fail (#expr, __ASSERT_FILE, __ASSERT_LINE, __ASSERT_FUNCTION)) The code in main.cpp works as expected and there were no errors. Then, I was working on a legacy codebase, which had the same format as the code observed in main.cpp, particularly, these two lines.. ... char *val = (char *)malloc(5); assert(val); ... Here I got an error. error: invalid ‘static_cast’ from type ‘char*’ to type ‘int' How? assert() does static_cast<bool> though, which worked fine on the main.cpp, but not here. Both code used C++11 standard and gcc-11.
Ashmond
hi, am new and want to learn c and c++
mito
I can't say why, but I think you shouldn't pay attention to it and just use explicit typing yourself. I wrote above that it is recommended to use exactly such types that are used in the function
The problem is that, even when I explicitly use something like, char *val = (char *)malloc(5); bool someVal = static_cast<bool>(val); I get, error: invalid ‘static_cast’ from type ‘char*’ to type ‘int' 💀 Since it's legacy codebase and it imports a lot of headers, is there a chance or possibility that somewhere in those user defined headers, there would be a custom assert macro/function ? Are user-defined functions have more precedence over a standard library one ?
mito
Simple Sorcerer
mito
Probably the assert in the legacy codebase defined differently
One of the headers used is from CppUnit framework and it has a custom assert() macro defined, haven't looked into it much though.
Simple Sorcerer
oh, okey
Simple Sorcerer
Explain here.
you must have already read that pointers = address in memory Let's go straight to the examples to make things clearer: int a = 10; int *b = &a; // get the address of a b is a pointer to MEMORY. it does not store the value 10. Now let's move to the memory pointed to by b. To do this, we need to DIFFER it (add *). int c = *b; // now c stores value 10
Simple Sorcerer
yes
Manav
By DIFFER you meant dereference, right?
Yep they mean that. * is a dereference operator in this case
Simple Sorcerer
By DIFFER you meant dereference, right?
I'm not really good at explaining it, but I can explain it some other way.
Manav
I guess i can try, what seems to be your issue? I am too lazy to scroll back up :D
Simple Sorcerer
I guess i can try, what seems to be your issue? I am too lazy to scroll back up :D
basic problem of assigning an address to a variable that works with integers
Manav
A pointer to an address where 3 is stored ?
Not entirely correct. Lemme ask you one more question before i explain everything int a = 3; What does this do? Gimme the most detailed answer, if possible.
Manav
I am not taking your test or anything, it's just to know how much you know about memory, etc.
mito
Not entirely correct. Lemme ask you one more question before i explain everything int a = 3; What does this do? Gimme the most detailed answer, if possible.
a is a name we give to an object. Here thr object is an integer stored at some place in memory. Since we have given a name for that object, it is a variable ?
Manav
a is a name we give to an object. Here thr object is an integer stored at some place in memory. Since we have given a name for that object, it is a variable ?
Yeah that sound correct, now lemme fill the gaps in your explaination. Assuming it's not optimized away (because compilers are aweswome :D). Lets talk about how it'll look usually. It will create some space (sizeof(int)) in memory for an int and then store the value 3 in there. Then a handle to this space which you can directly manipulate using the name a. You call this a variable
Manav
It's a bit simplified but that's what roughly will happen.
Manav
Now the location of this memory space is represented as numbers which you call address and this number can be stored in another variable. These are trated specially by C and are called pointers
Manav
Pointers also store type and alignment information but that outside of our discussion for now
Manav
int* p; Here what happens is that you declare that you want a pointer that can point to an address which will hold an int.
mito
What type is a pointer then, I assume something like, unsigned int/long to store large numbers (address) ?
Manav
int* p = &a; Now what you do is you tell it that i want this pointer to store the address of a, that is i want p to point to a.
Manav
What type is a pointer then, I assume something like, unsigned int/long to store large numbers (address) ?
Internally it's just a number. The size depends on the architecture but T* p; It's type is just T*
Manav
This keeps pointers seperate
Manav
Otherwise you might accidentally try to dereference an int for instance
Manav
Now to my question
Manav
int* p = &a; Now what you do is you tell it that i want this pointer to store the address of a, that is i want p to point to a.
int *p = &a; int* p2 = 3; Look at these two statements. &a gets you an address, which gets stored in pointer p
Manav
In other words you initialize a pointer with an address
Manav
T* t = <expr>; The result of <expr> will be treated as address so t can point to it
mito
I think I get it now..
Manav
I think I get it now..
Alright so lemme ask you questions then. I like it when people figure out stuff themselves
Manav
int* p = 3; int a = 32; // assume it's stored at memory location 0xb10 (binary repr) So what will std::cout << *p; print?
Manav
Some garbage value ?
No it'll print 32
mito
No it'll print 32
Wait isn't 0xb10 2 in decimal ?
Manav
mito
Lol
Manav
I meamt 0x11
mito
If it was 0xb11 then it would be 32
mito
Well you get it then
But, suppose that was not a mistake, but intentional, then the value printed can be whatever the data that was in that specific address at that point right?
вадим
Dm me
Can I too?
Manav
But, suppose that was not a mistake, but intentional, then the value printed can be whatever the data that was in that specific address at that point right?
Well not exactly but you're right. If 0x10 happens to be a valid virtual memory address then yeah it'll be some garbage value. It'll actually be an undefined behaviour. So don't use literals to intialize a pointer unless you know what you're doing
Manav
You mean like finding the mistake?
I mean explain whatever you were confused about, answering yourself essentially
mito
suppose, int a = 5; std::cout << *(&(*(&a))) ; Would this work ?