Anonymous
hello guys
Anonymous
who knows C++ and can help me
Anonymous
problem is very elementary
Nomid Íkorni-Sciurus
how much do you pay?
Anonymous
free
Nomid Íkorni-Sciurus
just joking
Javier
Hello, how do you access an array composed of arrays in C?
alessandro
bro do you know the base of c++?
Anonymous
no
klimi
Hello, how do you access an array composed of arrays in C?
Well, you can use the [] or pointer arithmetics
Bishmit
how will i find second last number after shorting array by bubble sort method ?? what is the logic
Bishmit
not 2nd last i mean 2nd largest although it will be in 2nd last from array but i can't find the logic to print it in output
Bishmit
Size -2?
i did the same but the ans comes so weird like 555555555
klimi
i did the same but the ans comes so weird like 555555555
and you sure the bubble sort is working?
Why not just write toInt = 0;
Yeah, but do u think it'll be safer?
Anonymous
undefined reference to 'libssh2_init' who know what the problem
Anonymous
i need help, bro
Anonymous
how link
Andrew
What are you using to code?
Anonymous
i alredy include_directories("/usr/local/libssh2/include")
Anonymous
CMakeLists.txt include_directories("/usr/local/libssh2/include")
Anonymous
drwxr-xr-x 2 root root 72 Nov 23 01:02 include drwxr-xr-x 3 root root 120 Nov 23 01:02 lib drwxr-xr-x 3 root root 17 Nov 23 01:02 share u mean is the lib?
Andrew
You're using linux?
Anonymous
my visual studio editor at my windows connector the linux
Andrew
If that when compiling just add "-lssh2" as param
Anonymous
remote compilation
Anonymous
can u give me the code?
Anonymous
i first time use c++
Andrew
Vscode or visual studio?
Anonymous
visual studio
Anonymous
only ask me cmake how line the library
Anonymous
include_directories("/usr/local/libssh2/include") include_directories("/usr/local/libssh2") this is ok? i add include_directories("/usr/local/libssh2")
Anonymous
ah, i change link_directories("/usr/local/libssh2/lib")
Andrew
Sorry im not experienced in C++ on the msvc compiler, but you need to add to linker the library, not only to include the header
Andrew
Do you have a makefile?
Andrew
https://learn.microsoft.com/en-us/cpp/build/reference/linking?view=msvc-170
Pavel
Yeah, but do u think it'll be safer?
It will make the code cleaner, because it what your line does.
mimi
Is the BFS of a tree is also a topsort of the same tree?
It will make the code cleaner, because it what your line does.
Updated! Thanks for helping! Also I'll try to fix the buffer overflow using asprintf instead sprintf
Anonymous
Guys who can help,
Anonymous
Problem is very elementary
Anonymous
I dont know C++ so i need help
Anonymous
But, i cannot pay
Bishmit
// finding how many pair of array element will have required sum #include<iostream> #include<vector> using namespace std; int main(){ vector<int> v{-1, 0, 1, 2, 3}; int key = 1; int pair = 0; for(int i=0; i<v.size(); i++){ for (int j=i+1; j<v.size(); j++){ if(v[i]+v[j]== key){ pair ++; } } } }
Bishmit
what is error in this code
Pavel
Updated! Thanks for helping! Also I'll try to fix the buffer overflow using asprintf instead sprintf
Was the problem in sprintf? I think it was in scanf https://stackoverflow.com/questions/64368589/how-to-avoid-buffer-overflow-using-scanf
Bishmit
can't we use 5th line vector initilization, i can do this in array but in vector it throws error
Pavel
Problem is very elementary
Hi, there's a problem with your request, it doesn't contain enough information to help you (you didn't describe what the problem is, what you have already tried to solve it, didn't show any code). Questions like yours are usually ignored, because nobody wants to pull information out of you. https://gameraccoon.com/2022/06/ask-good-questions-part-1/
Pavel
can't we use 5th line vector initilization, i can do this in array but in vector it throws error
You can use initializer_list like this: vector<int> v{{-1, 0, 1, 2, 3}}; Not sure how efficient it is when used with custom types that are expensive to move, but for ints should be fine.
Anonymous
Pavel
There is no difference between his and your way to initialize vector. In both cases the initializer_list constructor is called.
Hm, yes, I see you're right, I remember for me just using curly braces didn't work (it tried to call a normal constructor instead)
Michel
Where can I get a list of all the macros defined by the compiler? I'm even not sure how to ask what I want, I mean: I know, for instance, that there is a __LINE__ and a __FILE__ (macro ?, is this what they're called?) that I can use for compile time, where can I get the full list?
Michel
Even more specific, I'm working with CUDA, and I saw somewhere they handle error with this: #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) { if (code != cudaSuccess) { fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line); if (abort) exit(code); } } But I would like the error message to have not only the file and line but also some stack information. (Well, that didn't get specific enough) Is there any __CALLED_FROM__ or something similar that I can add to the error message?
Leonardo
ive got a segmentation fault on this code https://dpaste.org/UbyLg .With the debugger of replit i found out that its caused by strcpy at line 39 but idk why
Leonardo
ive got a segmentation fault on this code https://dpaste.org/UbyLg .With the debugger of replit i found out that its caused by strcpy at line 39 but idk why
the aim of this program is to find the longest word on the file text divina.txt wich contains the first chapter of "Divina Commedia" by Dante Alighieri
ዘገብርኤል
Guys please help me because I don't know anything about C++ programming language
klimi
Guys please help me because I don't know anything about C++ programming language
well, and we don't know anything that you might be facing because you haven't written anything
klimi
Do you know more about c++
"more" than what? Than your problem description? Yes...
klimi
#howtoask
𝕾𝖗𝖚𝖑𝖎
Hi everyone, Im new to programming (C++), and would appreciate some help here. I built a program that picks 10 random integers, and I want the program should output a message if it is in non descending order, how can I do it?
klimi
Ye but I need the program to do it
well just add it to your program that picks 10 random integers
𝕾𝖗𝖚𝖑𝖎
Basically I need the program to check if the first number <= than the second one…
𝕾𝖗𝖚𝖑𝖎
well just add it to your program that picks 10 random integers
I need to use the if function but not sure how
klimi
well... that's just simple if if (first <= second) {//code//}
𝕾𝖗𝖚𝖑𝖎
klimi
And do I need to do that for all 10?
if you want to check 10 numbers, you will have to do 9 comparisons