Anshul
Which apps do I need? And where will I get the resources
If you mean ide then go for any ide, I personally use visual studio
Sidharth Singh
I've set an target of 2 months from now.
Anshul
For leaning c++ or c++ with data structures
Madhav
I need apps for smart phone
I have already told you... Why are doing this again... What I have told is already enough.. If u want to learn c++
Anonymous
and i also have to delete first element after moving it to the back
You want a rotate left operation. But unfortunately bitset doesn't support such operations. If you need it, you will have to either "do a linear scan and move the bits one by one I guess" or "convert the bitset into a string and do the manipulations on the string and convert it back to a bitset". I can't tell you which would be better without any performance testing. But from the code's point of view, the second method would be more easily understood.
Emirlan
I think i will try to implement the second approach🤔
shriman_deepak
Given a K number, determine the smallest power of 2 which is bigger than K.
Anonymous
Anyone please.. just give me a hint
Look at the bits in the number. The smallest power of 2 greater than a number would have a 1 bit at the first 0 bit in the given number and the rest of the bits would all be 0
Anonymous
Sorry i didn't understand 🥲
If number is 5, the bits in it are 0101. So you want to return 1000. If number is 32, the bits are 0100000, then you want to return 1000000. This can be done easily by bit manipulations.
Typing...
How can I copy a integer value to another
Dr
How can I copy a integer value to another
Did you initialise the variable or is it the result of some function
Dr
If its a result, store it in a temp variable and call that variable
Typing...
I can't because it is an array in which I have to store the value.
Typing...
100
Dr
You can copy it by looping it and indexing it
Mickey🕷
Evaluate the following expressions i) 2>4 && (7<=8) || !(4); ii) int (3.0)*4/6+6; iii) ('A' % 2) == 0; Can I get the answers and explanation on how you reach those answers.
artemetra 🇺🇦
does strlen exlude the null terminator? because in the code i'm reading right now i see a lot of strlen(<str>) + 1, or is it for a different reason?
Ni
A quick question: std::vector<int> vec{1,2,3,4,-1,-2,-3}; auto res = std::binary_search(vec.begin() + 4, vec.end(), -1); std::cout << res << "\n"; why the code gives 0
Ni
Because the array is not sorted
I soppose {-1, -2, -3} is sorted, so the container must be sorted in increasing order?
Anonymous
A quick question: std::vector<int> vec{1,2,3,4,-1,-2,-3}; auto res = std::binary_search(vec.begin() + 4, vec.end(), -1); std::cout << res << "\n"; why the code gives 0
You do realize that -1,-2,-3 is not sorted as is required by binary search. It expects the elements to be in ascending order (actually not required to be sorted) while you have them in descending order.
Ni
thanks for your help!
Anonymous
Evaluate the following expressions i) 2>4 && (7<=8) || !(4); ii) int (3.0)*4/6+6; iii) ('A' % 2) == 0; Can I get the answers and explanation on how you reach those answers.
Can't you try it out on your compiler? You must read about operator precedence and associativity to understand how these expressions are evaluated.
Shahar
What's the inherent problem in developing an interpreter-like for C/C++? We can develop a program maintaining a source code file which is filled in by the interpreter user. Every time the interpreter user presses Enter, the interpreter compiles and runs the source/binary respectively - if there is an output which is not some error due to the possibility the user didn't finish to write his routine.
+
guys when I want to create a bunch of folder (that also have subfolders) with std::filesystem::create_directories its some times fail and say The filename or extension is too long. its right, because im trying to create a folder with like 14 subfolder, how can I do it?
Lxjxjxhks
Umm, I installed the command line tools in my Mac using this command arch -x86_64 /bin/bash -c "$(curl -fsSL http://bit.ly/homebrew_techdecode)" and then I did not installed any compilar, but whenever I run a c program in vscode, it shows that it's compiled by a gcc compilar, but I want to use clang and it already is installed idk how but when I used the command clang --version it shows installed and the version. So if now, I want to use clang to compile c program instead of gcc, how do I do it?
Anonymous
Thanks for inviting me
Anonymous
guys when I want to create a bunch of folder (that also have subfolders) with std::filesystem::create_directories its some times fail and say The filename or extension is too long. its right, because im trying to create a folder with like 14 subfolder, how can I do it?
This depends on the underlying OS. For example POSIX systems can't work with filenames longer than NAME_MAX characters. So in all probability it is the OS that is failing and C++ runtime library wraps it for you.
Anonymous
Slow - probably. Pointless - why?
Pointless because it is slow. The C++ standard committe has already proposed a REPL (it works differently from what you suggested above and has limited functionality) and it is yet to be approved AFAIK.
+
This depends on the underlying OS. For example POSIX systems can't work with filenames longer than NAME_MAX characters. So in all probability it is the OS that is failing and C++ runtime library wraps it for you.
yes, I know that, Im trying to use it on windows, and as you know the max path in windows is MAX_PATH so what can I do for it? I need to be able to create big paths...
artemetra 🇺🇦
Can't you look up the documentation? And yes it does not include the null character
i did loop up on cplusplus.com but found no info on that, thank you though!
Anonymous
i did loop up on cplusplus.com but found no info on that, thank you though!
Use cppreference. But I just searched for the cplusplus definition - https://www.cplusplus.com/reference/cstring/strlen/ And it clearly mentions this in the first line "The length of a C string is determined by the terminating null-character: A C string is as long as the number of characters between the beginning of the string and the terminating null character (without including the terminating null character itself)" So not sure what you read.
Anonymous
yes, I know that, Im trying to use it on windows, and as you know the max path in windows is MAX_PATH so what can I do for it? I need to be able to create big paths...
Write your own OS. How do you expect it to work if the underlying OS itself doesn't support it? You could create them layer by layer as an alternative workaround.
Anonymous
this is tested, but still not work https://godbolt.org/z/4ahqd5M1z
You are using Windows. Windows doesn't allow file lengths more than 260 characters and Windows checks this from the root. So even if you are not going to refer to the sub directories from the root, Windows still doesn't allow creating them. Try limiting your folder names to 2 or 3 characters.
Anonymous
What's the idea behind their suggestion?
It is a very limited feature set tool which allows basic things like constexpr and consteval functions and allows you to do some limited prototyping. These are things that the compiler can work with without invoking a linker.
Shahar
It is a very limited feature set tool which allows basic things like constexpr and consteval functions and allows you to do some limited prototyping. These are things that the compiler can work with without invoking a linker.
Why is the linkage problematic? If some linkage is required as regards to the inserted code, the interpreter will compile with the required linkage, etc...
+
You are using Windows. Windows doesn't allow file lengths more than 260 characters and Windows checks this from the root. So even if you are not going to refer to the sub directories from the root, Windows still doesn't allow creating them. Try limiting your folder names to 2 or 3 characters.
I can limit the folder names sadly (because I dont control them...) so I need to look for something else about creating them layer by layer I think its very heavy in performance side, because there is lots and lots of folder to create...
Anonymous
I've felt this need actually. Thank you
Propose it to the standards committee with reasons and if there are others like you, then maybe it might become a reality
Shahar
Don't know if it's right to bother the committee for this one
D
Guys
D
Please send me group about java
Alex
array<char, 5> d = {"sdfd"}; compiled vector<array<char, 5>> s1{{"asdf"}}; not compiled error: no matching function for call to ‘std::vector<std::array<char, 5ul> >::vector(<brace-enclosed initializer list>)’ vector<array<char, 5>> s1{{"asdf"}}; how to fix?
Ludovic 'Archivist'
This is literally the software that generated the picture of a black hole for the earth telescope project and the analysis for detecting the Higgs boson at LHC
Alex
It should compile fine.
I found issue. it compiles only from gcc 11.1(std=c++11 is used everywhere) for older compiler vector<array<char, 5>> s1{array<char,5>{"asdf"}}; works
Ludovic 'Archivist'
I think that the forwarding of the initializer list may have been the problem
Anonymous
I found issue. it compiles only from gcc 11.1(std=c++11 is used everywhere) for older compiler vector<array<char, 5>> s1{array<char,5>{"asdf"}}; works
Must be some gcc bug. In the godbolt link that you sent even a very old version of clang like clang 3.4.1 seems to be able to compile this fine with c++11 standard settings
Anonymous
This actually exists and is in widespread usage in the physics community since several years ago, look at root.cern
This looks great. I wasn't aware of this. Looks like an LLVM interpreter. So should be able to support majority of C++ features
Ludovic 'Archivist'
This looks great. I wasn't aware of this. Looks like an LLVM interpreter. So should be able to support majority of C++ features
Yeah, it is pretty good, I use it for statistics and simulations regularly. It is pretty fast and makes pdfs I can integrate in latex docs
Knights
Good evening Please I get this error statement...”the range-based for statement requires a suitable begin function and none was found” in my code This is the code double ScoresTotal(double testScore[], int numTests) { double total=0; int numTests=4; double testScore[numTests]; for(auto score : testScore) { total+=score; } } Anyone to help fix this error? Please🙏🏿
Dima
hmm wtf
Pavel
How do I know the c++ version I’m using
You provide the version to the compiler when you build the app, othervise it uses its defaults. You can try to find your compiler version and google what is the latest C++ version that it supports and how to set it during compilation.
Anonymous
Unfortunately you can't iterate over a C-style array with range-based for. You can either use std::array/std::vector, or wrap your array in std::span (if you use C++20)
You can iterate over an array using a range-for. The problem in his code I that he is trying to iterate on a pointer and not an array.
T3
Am new to c++,,can someone help me I sorting this out,,I need to arrange in descending order but it's like I got an error in it I can't solve,,any help
T3
#include<iostream> using namespace std; int main() { int n,i,j; int arr[]={4,7,9,3,5,6}; int temp=0; printf("%d",arr[6]); for( int i=1;i<n;++i){ for ( int j=i+1;j<n;++j){ if(arr[i]<arr[j]) arr[i]=arr[n]; { temp=arr[i]; arr[i]=arr[j]; arr[j]=temp;}}} for( int i=1;i<n;++i){printf("%d",arr[i]);} return 0; }