Hidd3N
/get
Vlad
U mean laptop or mobile phone?
You won't be coding with mobile phone if you're not masochistic))
Anonymous
learn a bit of basics first before c++
No problem I don't.. but I don't have resources to start learning it
Hidd3N
No problem I don't.. but I don't have resources to start learning it
Check youtube, there are plenty of resources available
Vlad
>What's your OS
Hidd3N
Linux mint 20
Vlad
Hp
Then I bet it's Windows
Anonymous
Vlad
Yeah window 10
Download Visual Studio then
klimi
Where?
Vlad
Do you know how commands work?)
Anonymous
Download Visual Studio then
Oky sure.I'm able to code offline with it?
Vlad
Pass smth to it lmao
Vlad
It's like ADDFILE in doom and you don't specify which one
Vlad
Of course it will say that you're moron))). But a bit lighter.
Nils
yes but all programming language
Ouch never a good idea, people will start arguing about which languages are the best
Dima
no, visual studio
Vlad
Vs Code?
Both will do. But vs code requires at least some terminal knowledge, which he clearly doesn't have.
Anunay
Yeah window 10
CLion + clang
Anunay
Visual studio is also a good option
sree nandhan
hey guys ... if I place a malloc function in a infinite loop and execute it without using free(). Will the pc actually run out of free ram ? .
Rajesh
I'm really sorry
Asdew
hey guys ... if I place a malloc function in a infinite loop and execute it without using free(). Will the pc actually run out of free ram ? .
Well, infinite loop, yes, of course. That's infinitely taking up more and more memory. What are you trying to do?
Asdew
It's like a library. You loan (malloc) a book (memory) of some size and then return (free) it to the library when you're done with it. If the library (memory) runs out of books (memory), you can't loan (malloc) anything and neither can anyone else (other programs).
Vlad
Although your program will crash eventually
Pavel
Actually it may not
Yes it may fail to allocate big enough block of memory, but there still can be free memory left
sree nandhan
Asdew
When the program terminates, the memory gets returned to the operating system for later allocation.
Vlad
Yes it may fail to allocate big enough block of memory, but there still can be free memory left
I mean that OS won't treat it as your program's memory until you make a change to memory page
Asdew
Actually it may not
We're trying to teach a beginner with a question. There isn't a need to know this as a C programmer.
sree nandhan
I mean that OS won't treat it as your program's memory until you make a change to memory page
oh ... so until when there is a change made in the allocated memory any other program can use it ? is it so ?
sree nandhan
thanks guys ... this is helpful :)
Ajay
I am learning to debug using lldb, is it just g++ -g filename.cpp and then lldb a.out ?
Ajay
This takes in some input and when I run provide it the required inputs then despite having some statements in the program that should give Undefined behaviour, it shows me Process 46756 exited with status = 0 (0x00000000) .
Vlad
All your addresses are virtual in a sense
Ajay
I've named it 3 or 4 times already ))) LLDB
I did that with lldb but says the above thing.
Ajay
The below code just pops an empty queue. Shouldn't that be caught with the debugger? #include<iostream> #include<queue> #include<vector> #include <utility> int main(){ int n;std::cin>>n; std::vector<int> a(n); std::priority_queue<int> q1, q; for(int i=0;i<n;++i){ std::cin>>a[i]; q1.push(a[i]); // q.push(a[i]); } q.pop(); return 0; }
Anonymous
I start c+++
Anonymous
C++*
Anonymous
Now where can i practice programs
@𝑺𝒐𝒃𝒌𝒂
/get
Ajay
You mean it crashes but the debugger does not catch it?
Not so, I mean it simply doesn't catch it. Nothing less, nothing more
Ajay
Also this: bool onlyEvensInArray(){ int numbers[2]; for (int index = 0; index <= 2; ++index) { if (numbers[index] % 2 == 0) return true; } return false; }
Vlad
It only says where SIGSEGV signal was raised
Pavel
Not so, I mean it simply doesn't catch it. Nothing less, nothing more
Did you compile with optimizations disabled? -Og flag for GCC as I recall Because otherwise it can optimize some lines of code and they will be skipped by the debugger
Vlad
It doesn't catch every out of bounds error
There's address sanitizer for that
Pavel
you mean the debugger?
No, your source
Ajay
There's address sanitizer for that
you mean compiling should be like g++ -fsanitize=address -g filename.cpp?
Ajay
I compiled like g++ -g filename.cpp.
Ajay
Yep
Is that the flag I should set when debugging?
Vlad
For the same reason why it isn't on godbolt
Vlad
sorry didn't get that.
It preallocates a lot of ram and does checks
Ajay
Try adding -Og or -O0
for the queue program, it still says Process 76390 exited with status = 0 (0x00000000) 😭 for the array out of bounds, it says Process 77122 exited with status = 1 (0x00000001)😁
Pavel
for the queue program, it still says Process 76390 exited with status = 0 (0x00000000) 😭 for the array out of bounds, it says Process 77122 exited with status = 1 (0x00000001)😁
Ok, but I thought you want to step into these functions with the debugger. About the issues with memory Vlad already suggested a solution
Ajay
It only says where SIGSEGV signal was raised
I didn't see that being displayed while debugging.
Vlad
It's called UB for a reason :P
Anonymous
Ouch never a good idea, people will start arguing about which languages are the best
Each language has its own use And the best programming language is only the best of its kind! On the other hand, there is disagreement as to which language is better
Nurlan
Wow