ㅤ
ㅤ
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
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
klimi
Bishmit
Size -2?
i did the same but the ans comes so weird like 555555555
klimi
Pavel
Anonymous
undefined reference to 'libssh2_init'
who know what the problem
Anonymous
i need help, bro
Andrew
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")
Andrew
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
Andrew
olli
mimi
Is the BFS of a tree is also a topsort of the same tree?
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
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/
Anonymous
ㅤ
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?
klimi
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?
Since these macros get processed in preprocessor, I don't think you can include the stack information as there is none when compiling the program
Ron
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?
If you want print the stack trace out when your meet unexpected error, backtrace is what you need. Search "backtrace" for how to use it. But for C++ I recommend you use Backward-cpp, you can find it on github.
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
ዘገብርኤል
Guys please help me because I don't know anything about C++ programming language
ዘገብርኤል
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
𝕾𝖗𝖚𝖑𝖎
𝕾𝖗𝖚𝖑𝖎
Basically I need the program to check if the first number <= than the second one…
𝕾𝖗𝖚𝖑𝖎
klimi
well... that's just simple if
if (first <= second) {//code//}
𝕾𝖗𝖚𝖑𝖎