Anonymous
C++ had something like a Java @Anotation
Jillur Rahman
Is bits/stdc++ header file includes every other single file in C++?
Jillur Rahman
Does*
Anonymous
Can u get me a link?
https://quuxplusone.github.io/blog/2018/12/11/dont-inherit-from-std-types/#:~:text=Never%2C%20ever%20inherit%20from%20any%20std%3A%3A%20type.
Chat Boss
Tej S sent a huge message, it has been re-uploaded as a file > Admin > Desktop > C D2.c 1 #include<stdio.h> 2 #include<conio.h> 3 void main() 4 f م 5 ..
Anonymous
C++ had something like a Java @Anotation
C++ has attributes but you can't create your own attributes like you can create annotations in Java. You have to live with the ones provided by your standard or compiler.
Anonymous
Hie can u convert kilometres to meters?
try it once on your own, if you still cant make it then text me I can look into you code
Anonymous
My second one still i can't convert kilometres to meters
Anonymous
I agree its my homework but i tried
Anonymous
I agree its my homework but i tried
Change meter-kilometer*1000; to meter = kilometer*1000; And while printing your output use %f format specifier.
Anonymous
Okay thanks 👍😊
Anonymous
what is a pure virtual function
Get a good C++ book or search for it online. One of the rules for this group is to search online for an answer to your question before asking it here.
Anonymous
https://isocpp.org/wiki/faq/virtual-functions#pure-virtual
/
i have a question that i have never made
/
can i do virtual void ProcessFile() = FUNCTION_POINTER; ?
Anonymous
can i do virtual void ProcessFile() = FUNCTION_POINTER; ?
I don't know what that is supposed to mean. If you meant to ask if you can assign the address of a virtual function to a pointer to a member function then the answer is yes
/
No
yes i understanded
'''''''
what's the diff between unordered_multiset and unordred_map? from what I understood both store the elements with their count
noalcoholatwork
what's the diff between unordered_multiset and unordred_map? from what I understood both store the elements with their count
Unordered map stores data in key value pairs, while multiset would only store the keys. In unordered map, the value can be anything, not necessarily an integer.
IDCAN
Hello guys how to check exists external process by pid? I found smth about int kill(pid_t, int); But i cannot import it, there is no this function idk why
Anonymous
Hello guys how to check exists external process by pid? I found smth about int kill(pid_t, int); But i cannot import it, there is no this function idk why
Are you on a POSIX system? The function prototype is in signal.h header. To check if a pid is valid, you can call this function like kill(pid, 0). If this call returns -1 and errno is set to ESRCH then it means the pid does not exist. If it returns 0, it means the PID is valid. But remember that even if the PID is valid, it may not refer to the process you expect. That process could have died and another spawned process could have taken on the same pid value.
Rashid
Void ( ) { Int digit ; For (digit = 0; digit<=9; digit++) Cout<< digit <<"/n"; Digit = 5*digit; - - digit; } Why the output is 49?
Mahmoud
Hello I wrote a code as stack in c++ and I run the code it run but it give me different path can someone help me to know what is the issues?
Mahmoud
i didnt send the code bcz i cant send it in the groupe
Hritik
I want to take few characters as input but the exact number is now known... How can i do it in c++?
klimi
I want to take few characters as input but the exact number is now known... How can i do it in c++?
you take n numbers, try if it is all, if yes, you are done, if not, you take another n (or you do doubles)
Hritik
you take n numbers, try if it is all, if yes, you are done, if not, you take another n (or you do doubles)
No like for different test cases there will be different value of n and it's not provided in the question
klimi
No like for different test cases there will be different value of n and it's not provided in the question
well... what's wrong with reading it by parts? I mean where is my algorithm wrong
klimi
But how will i know if i took all the inputs?
well you will read to the end and get EOF? (End of File) or you would get end of line (EOL) if you want only one line parse. Or you would read character that is not a digit
Hritik
I tried using ... While(cin.get(c)){ if(c=='\n') }
klimi
Can you give an example? Please
you are loading number 12345678, you guess the length is 4 so you read "1234"; you haven't read EOL/EOF so you read 4 more characters "5678", no EOL/EOF, you try reading 4 more, but you get EOF instead so the number must be "1234""5678"
klimi
I tried using ... While(cin.get(c)){ if(c=='\n') }
of course you could read it char by char, that would work too
Hritik
https://pastebin.com/jqNiwPFK
klimi
Check this code
ye... i cannot understand that code
Hritik
ye... i cannot understand that code
In line 15 if i use cin.get program doesn't works ... But if i use for loop it does work but i have to fix the value of n
Hritik
Basically I'm saying cin get isn't working for me so any alternative for that or what I'm doing wrong
noalcoholatwork
I want to take few characters as input but the exact number is now known... How can i do it in c++?
you can just take a string input? string s; cin >> s; doesn't require you to take length of string
Dimka
could you please recommend c/c++ build systems. i know about Cmake(but it is hard to use, as for me). I also heard about bazel, its declarative syntax look nice. so, guys, any suggestions or maybe your own experience?
Anonymous
could you please recommend c/c++ build systems. i know about Cmake(but it is hard to use, as for me). I also heard about bazel, its declarative syntax look nice. so, guys, any suggestions or maybe your own experience?
Cmake is the best option as it is the one most used. It is right now the defacto standard build tool for the C++ community. So learning and sticking with it would be the best option. If you want something that has extensive support for C++20 modules then b2 is the best. But it's language is worse than CMake and trying to understand it is a pain. I tried and failed. Bazel is good but it expects your code to be organized in a Google specified way and it is hard to make it work with dependencies that don't use Bazel themselves forcing you to write bazel files for other projects that you don't maintain. If you want a build tool that is written in a simple and direct way and is close to English language then Meson is the best. But again it is not widely used by the C++ community but those who have used it often wonder why other build scripts couldn't have been designed this way. I use Meson for simple projects and used CMake at work. Between the two, I love and prefer Meson but unfortunately CMake is hard to ignore because of its widespread use. Modern CMake is not that bad anyway
ynwqmv
why if i delete 2 times (f.e i forgot) array (heap) it does not matter, i will get double free detected error, but when i make something like : array = nullptr; and delete the array second times in another place of the program i wont get the error. Because of that the nullptr makes pointer of variable NULL (0x0000000) and if we delete this memory many times with ::operator delete nothing will happen yea???
Eugene
No array != Nullptr ,array = any pointer
Danya🔥
why if i delete 2 times (f.e i forgot) array (heap) it does not matter, i will get double free detected error, but when i make something like : array = nullptr; and delete the array second times in another place of the program i wont get the error. Because of that the nullptr makes pointer of variable NULL (0x0000000) and if we delete this memory many times with ::operator delete nothing will happen yea???
When you delete an array, the memory allocated to the array is deallocated and returned to the heap. If you try to delete the same memory again, you will get a double free error because the memory has already been deallocated. In the case where you set the array pointer to nullptr, the pointer no longer points to the memory previously allocated to the array. If you then try to delete the memory again using this null pointer, it is safe to do so because deleting a null pointer has no effect. The reason for this is that the delete operator checks whether the pointer is null before trying to deallocate the memory. If the pointer is null, the delete operator does nothing. However, it is important to note that setting a pointer to null after deleting the memory is not a solution to the double-free problem. This is because the memory that was previously allocated to the array is still potentially accessible until the pointer is set to null. If you try to access that memory using the pointer after it has been deleted, you will get undefined behavior. It's always a good practice to ensure that you only delete memory once and avoid using null pointers to try and prevent double-free errors. If you're not sure whether a pointer has been deleted or not, you can set it to null after deleting it to prevent any accidental use, but you should still be careful to avoid accessing the memory that was previously allocated to the pointer.
Danya🔥
Man, ChatGPT is great
Danya🔥
did ChatGPT generate it?
Yes I wouldn't even dare trying to understand what the person meant
Danya🔥
ChatGPT would be really helpful in this chat
Danya🔥
ChatGPT would be really helpful in this chat
But I think OpenAI would go bankrupt then
Sebas Tian
When you delete an array, the memory allocated to the array is deallocated and returned to the heap. If you try to delete the same memory again, you will get a double free error because the memory has already been deallocated. In the case where you set the array pointer to nullptr, the pointer no longer points to the memory previously allocated to the array. If you then try to delete the memory again using this null pointer, it is safe to do so because deleting a null pointer has no effect. The reason for this is that the delete operator checks whether the pointer is null before trying to deallocate the memory. If the pointer is null, the delete operator does nothing. However, it is important to note that setting a pointer to null after deleting the memory is not a solution to the double-free problem. This is because the memory that was previously allocated to the array is still potentially accessible until the pointer is set to null. If you try to access that memory using the pointer after it has been deleted, you will get undefined behavior. It's always a good practice to ensure that you only delete memory once and avoid using null pointers to try and prevent double-free errors. If you're not sure whether a pointer has been deleted or not, you can set it to null after deleting it to prevent any accidental use, but you should still be careful to avoid accessing the memory that was previously allocated to the pointer.
i thought a nice respost, but it really looks like it was generated by ChatGPT
Pavel
Man, ChatGPT is great
Except that the last two paragraphs don't really make sense :)
Pavel
why if i delete 2 times (f.e i forgot) array (heap) it does not matter, i will get double free detected error, but when i make something like : array = nullptr; and delete the array second times in another place of the program i wont get the error. Because of that the nullptr makes pointer of variable NULL (0x0000000) and if we delete this memory many times with ::operator delete nothing will happen yea???
For simplicity you can think of a pointer as an address to the memory. When you allocate something, you get address to that, no other parts of the program know that something exists in that memory. If you delete it, the address is still points to that memory, even though that memory is freed (doesn't belong to your app anymore). If you try to delete an object by that address again you get undefined behavior (you can hope it be just a crash). Calling delete on NULL does nothing, so if you null a pointer after deleting it, then you 1. can check if it still points to something by comparing to NULL 2. can delete it safely (e.g. in an object destructor) Note that if you have two pointers to one object, if you null one of them the other will still point to previous memory, so it won't save you from double free problem. In C++ there are mechanisms that help you not to think about all these things called "smart pointers", they manage ownership, free memory when you don't need it anymore (prevent memory leaks), set themself to be nullptr when they are freed and do other safety things. Also, in C++ we use nullptr instead of NULL, nullptr is safer type wise, can't accidentally use it as number.
Mohamed
error: expected initializer before 'int' what is that ?
Chat Boss
Mohamed Salah sent a code, it has been re-uploaded as a file
Anonymous
Do we have a huge difference between clang, mscv, or gcc? I will have some troubles later when I'll using for example clang instead of mscv currently?
Ashish
How to start C programming from beginning
klimi
How to start C programming from beginning
You learn and code, see the pinned message for some resources or search online 👍
Pavel
Do we have a huge difference between clang, mscv, or gcc? I will have some troubles later when I'll using for example clang instead of mscv currently?
There are small compiler-specific things, that work only on a specific compiler (or don't work only on a specific compiler). Overall you don't need to worry about that, it is not very difficult to fix those issues usually if you want to switch between compilers (especially between GCC and Clang).
Anonymous
Hello? I am new learning C++, how to code it Ubuntu?
Anonymous
It seems to me that everyone here are great beacause I am a C++ beginner.
\Device\NUL
Hello? I am new learning C++, how to code it Ubuntu?
Your bio saying that you're a C++ developer '-')/, why not just google setup C++ on linux
Anonymous
Actually i ain't C++ developer lol
\Device\NUL
Is bits/stdc++ header file includes every other single file in C++?
Never use non standard header! It just a lazy person that use #include <bits/stdc++.h
Vadana
Is there a file around where dynamic allocation is explained?