DEV 7
I got run time error in this program This is a merging two sorted array #include<iostream> using namespace std; int main(){ int arr1[5]={1,8,10,12,20}; int arr2[3]={0,2,6}; int sorted[8]; int pos1=0, pos2=0; for (int i=0; i<8; i++) { if (arr1[pos1]<=arr2[pos2]) { sorted[i]=arr1[pos1]; pos1++; } else { sorted[i]=arr2[pos2]; pos2++; } } for(int i=0;i<8;i++){ cout<<sorted[i]<<endl; } return 0; }
Anonymous
Hey any one draw a system model for a school system using structure chart
Sandeep
Can we sort a string using sort function
Anonymous
how do i split a vector into multiple vectors that contain duplicates of whatever elements are found? eg { 1, 1, 2, 3, 3, 2, 4 } -> {1, 1}, {2, 2}, {3, 3}, {4}
Anonymous
how do i split a vector into multiple vectors that contain duplicates of whatever elements are found? eg { 1, 1, 2, 3, 3, 2, 4 } -> {1, 1}, {2, 2}, {3, 3}, {4}
Well surely there is some fancy way of doing in with the std template library. However, i would do it like that: 1) sort vector1 2) create vector2 of type vector<vector<int>> for examplr 3) iterate over vector1 4) create a tmp variable 5) create a new vector everytime the current elements value != the tmp value. 5) save value of current element in a tmp variable. 7) memorize that vector as current vector and push it back to the vector2 8) if tmp == current value, then push that value back to the current vector.
Данил
What IDE do you use for C++ develop in macos?
Shahar
Can you show us how you are testing the library (a MVCE)? You can use a site like pastebin.com to post your code
Using GoogleTest framework on Linux machine. Also, my IDE is CLion. I've managed to solve this certain problem, the problem was that an exception was thrown, so the program actually exited by the exception and not by my std::exit. Thank you
Anonymous
Using GoogleTest framework on Linux machine. Also, my IDE is CLion. I've managed to solve this certain problem, the problem was that an exception was thrown, so the program actually exited by the exception and not by my std::exit. Thank you
My point was to see how you you were testing exit code from threads and to see if you inadvertently were seeing exit codes from a thread other than the one you were checking. Since you have solved your problem already this is a moot point anyway
Anonymous
Yeah. And I checked it using ASSERT_EXIT routine provided by the GoogleTest framework
If you have doubts on what exit code was used and you are within the assembly of std::exit before the exit handlers are called, you can just check the value of register rcx before it is set to 1 and see if that value is what you passed in
Shahar
How can I permanently configure CLion to always going through the forked process while debugging the program? For now, every time I want CLion's GDB to include the debugging execution of the forked process, I have to initially breakpoint at the thread which forks, typing in GDB console these two commands: set follow-fork-mode child, set detach-on-fork off, and then typing continue to get into the second breakpoint inside the forked process.
Anonymous
What IDE do you use for C++ develop in macos?
For any os, just use vim. It takes some time to get used to and to configure it they way you need it, but you will be more productive in the long run. Also there are great plugins for vim/neovim that can support you with suggested keywords and so on
Anonymous
For any os, just use vim. It takes some time to get used to and to configure it they way you need it, but you will be more productive in the long run. Also there are great plugins for vim/neovim that can support you with suggested keywords and so on
Vim aint a IDE though. It's really useful to know vim shortcuts and key combinations but it's just a text editor I use VS Code and I find it pretty good considering it's free @Ninos122, if you're a student you could be eligible for clion discount/free license, it is really good too
Anonymous
Also, you can import vim key combinations in VS code too
Anonymous
For me any editor especially suitable to code in, meaning you can have syntax highlighting and a shortcut to run your code is an ide 😅
Anonymous
For me any editor especially suitable to code in, meaning you can have syntax highlighting and a shortcut to run your code is an ide 😅
That's the definition of a text editor. A IDE offers different tools. Between them you can find a text editor (ofc), usually a debugger and building/compiling tools
Anonymous
This is a IDE. Vim is not a IDE
Anonymous
Vim is as much of a IDE as Atom or Sublime Text
Anonymous
That's the definition of a text editor. A IDE offers different tools. Between them you can find a text editor (ofc), usually a debugger and building/compiling tools
Nwver said it was. But i mean i have that in vim as well through plugins and shortcuts in the configuration, so whats the difference to a "real" ide
Anonymous
As said i can't tell them apart
Anonymous
Im actually serious. Is there any clear definition? If i pick any feature for example that an ide like kdevelop might offer, i can have that in vim as well. So yeah. If vim is not an ide or can be used as one, give me a reason to why that is 🤷‍♂️.
Anonymous
surely vim is mostly meant to be used as a plain text editor, but yeah.
Anonymous
Thats the only difference i see. The intention it was developed with
Anonymous
everything
Give me one point, just because i feel like arguing ^^
Anonymous
Well i thought so lol
Anonymous
Give me one point, just because i feel like arguing ^^
A quick internet research will do 🥲
ian
lol
Anonymous
A quick internet research will do 🥲
Sure, go ahead and search for one point vim is not capable of anything your ide can do :)
Anonymous
possibly they are some. Either way, there have been dedicated IDEs that still qualified as an ide without any real debugging interface for example. I cant find any point where vim comes short in assisting the developer to develop compared to other full blown IDEs
a Semicolon
Hi Anyone have done something in C++ detour/ function hookings?
Sandeep
string word = arr[i]; char letters [word.size() + 1]; strcpy(letters, word.c_str()); Arr is an array of strings.. Can't we just pass word to strcpy..why c_str
Golden Age Of
string word = arr[i]; char letters [word.size() + 1]; strcpy(letters, word.c_str()); Arr is an array of strings.. Can't we just pass word to strcpy..why c_str
c_str() returns a raw pointer of string ,(class string is polymorphic wrapper on classic C style string) Strcopy works with POINTER to real string, if you pass it just word without converting to C style string , then strcopy won't get all array of letters, only some reference to object String
Golden Age Of
What do you mean some references
I meant if you pass to strcopy object of string, you will pass it reference to the OBJECT not to the pointer to the string which this object contains
Golden Age Of
String is class which has many functions and POINTER, this pointer is filled when you call constructor (string word ="word"), So here we go, strcopy GETS pointer to array of letters (classic C style string, const char* arr), AND when we pass our STRING object to strcopy, we actually try to give it reference to the OBJECT of string, we dont give it real string, where stored real array of chars, so it won't work. And there , to make it work, we need to call function c_str() of STRING OBJECT, to return this raw pointer which points to real array of chars to make strcopy see what he must work with.
Golden Age Of
Plz let me know if I understood it properly....when you pass a string it is not instantiated ..hence there is no pointer(so no pointer is passed)..which is why I need to convert it into c_str
Yes, exactly, when you pass object of string, your strcopy doesn't know that string contains some pointer to array of letters, so you need to call c_str() to return this pointer to strcopy
Golden Age Of
You assign the pointer inside of WORD object with some value of arr[i] (no matter is there 1 symbol or more ,it's still string), Then you create C style array with size of your string(probably its gonna be 2) And after that all, you want to assign your C style string, with value of string object. So you call strcopy, first parameter is an array where value will be pasted, and second parameter is COPIED element. Two of these parameters must be C styles strings(pointers to arrays of letters) as first parameter you passed C styled string *letters*, so there s no need to convert, AND as second parameter you pass an OBJECT of string which contains real pointer to an arr of letters, but strcopy doesn't know it beforehand, so you call c_str() to say strcopy : "Hey bro, im object, but look, I have a pointer for you which points to the array you need, take it"
Golden Age Of
Yodin
Rvggg
Roxifλsz 🇱🇹
/ban ad
Anonymous
Hi Anyone have done something in C++ detour/ function hookings?
surely. Asking for Game Hacking or Malware XD ?
a Semicolon
Finally someone Yes game hacking😂
Anonymous
did you take a look at the guided hacking tutorial series on it :p ?
a Semicolon
They do it for Windows
Anonymous
ah i see. I'm not sure if i can help there, i did very little on android solely for windows and linux i did any game hacking. On android i really only did some packet analysis and regular development
Shahar
This is my project's CMakeLists.txt: CMake # Almost all CMake files should start with this # You should always specify a range with the newest # and oldest tested versions of CMake. This will ensure # you pick up the best policies. cmake_minimum_required(VERSION 3.1) set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") project(threads VERSION 1.0 LANGUAGES C CXX) add_library(uthreads uthreads.h uthreads.cpp thread.h Thread.cpp Scheduler.h Scheduler.cpp uthread_exception.h uthread_exception.cpp uthread_utilities.h uthread_utilities.cpp) set_property(TARGET uthreads PROPERTY CXX_STANDARD 11) target_compile_options(uthreads PUBLIC -Wall -Wextra -DNDEBUG -pedantic -g) add_subdirectory(tests) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) Using CLion IDE, I'm getting into a source file in the path: tests/tests_to_be_ran_separately.cpp, and for some reason, it suddenly doesn't recognize any other file of the project, like uthreads.h. When I'm trying to navigate to some function definition from this source file, it says: cannot find declaration to go to. Does someone have an idea as for why it happens?
Aze
there's a slight difference between c and c++,so can we have a separate group for both..with both having this has it's parental platform.Or what do you think guys?
DEV 7
c++ program to find square root of integer/float type value without inbuilt function
DEV 7
You can find in Google
in google they use inbuilt function
Anonymous
https://onecompiler.com/c/3w5ukfyrm
Anonymous
Please give me output of this problem
Anonymous
Please urgent
Ammar
Please urgent
Nobody cares about your urgency. Saying urgent won't make you get faster answer. It's rude, you shouldn't say that on public forum. https://meta.stackoverflow.com/questions/326569/under-what-circumstances-may-i-add-urgent-or-other-similar-phrases-to-my-quest
Anonymous
This is my project's CMakeLists.txt: CMake # Almost all CMake files should start with this # You should always specify a range with the newest # and oldest tested versions of CMake. This will ensure # you pick up the best policies. cmake_minimum_required(VERSION 3.1) set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") project(threads VERSION 1.0 LANGUAGES C CXX) add_library(uthreads uthreads.h uthreads.cpp thread.h Thread.cpp Scheduler.h Scheduler.cpp uthread_exception.h uthread_exception.cpp uthread_utilities.h uthread_utilities.cpp) set_property(TARGET uthreads PROPERTY CXX_STANDARD 11) target_compile_options(uthreads PUBLIC -Wall -Wextra -DNDEBUG -pedantic -g) add_subdirectory(tests) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) Using CLion IDE, I'm getting into a source file in the path: tests/tests_to_be_ran_separately.cpp, and for some reason, it suddenly doesn't recognize any other file of the project, like uthreads.h. When I'm trying to navigate to some function definition from this source file, it says: cannot find declaration to go to. Does someone have an idea as for why it happens?
I am not sure I understand the context clearly. What has your CMake file got to do with IDE not able to search for source code? I am not sure the IDE uses the CMake file to decide where the source code is located (not sure about CLion though). It is used mostly by the build generator and the build tools. This error would probably be resolved by your IDE settings/preferences flags/options.
Anonymous
klimi
#ot
𝕮𝖍𝖊𝖙𝖆𝖓∆
Ok
Anonymous
How does the IDE navigate to included files?
Through some specific setting for your project which would specify the include directories.