mito
If you want to know what's actually happening regardless of any high level language, look at assembly code, it's a level higher than binary language.
mito
Yes, you can.
mito
You can use GNU debugger.
mito
Yes
M
#include<iostream> using namespace std; int fib(int x){ if(x<2){ return 1; } return fib(x-2)+fib(x-1); } int main(){ int a; cout<<"enter the number for finding fib"<<endl; cin>>a; cout<<"the fact is "<<<fib(a)<<endl;
mito
https://godbolt.org/ Or use this website. It's pretty handy.
M
#include<iostream> using namespace std; int fib(int x) { if(x<2){ return 1; } } return fib(x-2)+fib(x-1); int main(){ int a; cout<<"enter the number for finding fib"<<endl; cin>>a; cout<<"the fact is "<<fib(a)<<endl; }
mito
Bro... Is there any offline software for it
Yes, GNU debugger, IDA, Ghidra, x64/32 dbg, many more for debugging assembly level code.
M
Now can I know what happens in return fib(x-2) + fib(x-1)
M
Actually I want to know how compiler is preserving value of variables
M
In each bit of command
²
Bro... Is there any offline software for it
gcc -Wl,adhl i dont remember full comand
mito
Actually I want to know how compiler is preserving value of variables
Compile that program, then download x64dbg and run it. Open your Fibonacci executable and run it. Attach the Fibonacci program process to x64dbg and set breakpoints at assembly code and observe the registers and program flow. This is the easy way using GUI. If you want command line, then use GNU debugger it is simple. You first need to learn assembly and how data is stored in registers and all to know atleast how everything works at low level.
Chika
Is it possible to convert from a string datatype to an int datatype in c++?
Hizmu(Vlad)
Hi guys. Tell me how best to do it. My project consists of 3 libraries. 1. The library is built on mongoc that connects to mongodb 2. Log - built on spdlog 3. Account - which registers the user, authorization, and so on. And I think how to do database logging. So far, I just have spdlog output. But how is it better to return an error from the library? With getError(), or create an ErrorHandler class, or let's say collection.find() should go as an error return value? If create an ErrorHandler then how to combine it with spdlog ? if getError() then what is it to return, a string or a struct?
Pavel
Is it possible to convert from a string datatype to an int datatype in c++?
there are multiple ways if you don't want it to throw exceptions but still want to handle errors, you can do it this way: https://github.com/gameraccoon/tank-game/commit/0574876b65b09418804cdd007294a2f84e7ec2a4
Dbdb
How do you use C for hacking. How do you even start
Check github for some nice viruses....run only the mild ones though, you could easily find yourself ruining your life 😂
Anonymous
Hi guys. Tell me how best to do it. My project consists of 3 libraries. 1. The library is built on mongoc that connects to mongodb 2. Log - built on spdlog 3. Account - which registers the user, authorization, and so on. And I think how to do database logging. So far, I just have spdlog output. But how is it better to return an error from the library? With getError(), or create an ErrorHandler class, or let's say collection.find() should go as an error return value? If create an ErrorHandler then how to combine it with spdlog ? if getError() then what is it to return, a string or a struct?
This depends on a lot of things. There is no one right answer. This depends on your code, your architecture and your Long Term Vision plans. Basically you want a mechanism to do error handling from the Account library. How you do this depends on what clients of this library expect from the chosen error handling mechanism. Are you intending to create an alternative for clients to do if a call to your library fails? Or is the error that you return from your library just a FYI that you expect the client to log and not be able to do much after that. If it is the former case, then designing an exception hierarchy would be a choice. If your organisation doesn't allow exceptions, then you can return a struct with as much information as possible to help the client recover or try alternatives. If it is the latter case then you can return a error string encapsulated in a DBError struct (this allows you the possibility of extending this struct in future). (Look at std::expected. This class is like EitherOr in Functional programming languages that aids with better error handling mechanisms. It is available only in C++23 but is easy to implement using C++14 itself. There are many implementations available). The client can log the error string (if it is not a library itself) or pass it on to upstream clients (if it is another library) to inform about the error or even wrap it in an exception. Again, like I said there is no one right answer and the choice depends on your needs and your future plans.
Hussein
Bro... Is there any offline software for it
you can do this with your compiler on gcc you can compile your file like this: gcc -S file.c
SR27
int main() { int p=5; int &k=p; k=2; //printf("return value %d",f(p,p)); printf("\nafter work %d",p); return 0; }
SR27
it gives error
SR27
please help
Anonymous
post the error
SR27
main.c: In function ‘main’: main.c:18:9: error: expected identifier or ‘(’ before ‘&’ token 18 | int &k= p; | ^ main.c:19:6: error: ‘k’ undeclared (first use in this function) 19 | &k=3; | ^ main.c:19:6: note: each undeclared identifier is reported only once for each function it appears in
Anonymous
i think what you want to do is int* k = &p
Anonymous
oh that’s right ahah i didn’t even realize it was c
SR27
#include<stdio.h> #include<stdlib.h> // using namespace std; int f (int &x, int &c) { x=4; c=5; return x*c; } int main() { int p=5; printf("return value %d",f(p,p)); return 0; }
SR27
even this will not work in c ?
SR27
just want o confirm
Dumb
you are using the addresses of parameters in f
Pavel
even this will not work in c ?
I think it won't work (I'm not a C expert)
Dumb
you are using the addresses of parameters in f
so you have to call the address of that invoked variables in your case *p
Pavel
f(*p,*p) {i made confusion, sorry about that}
You don't need to dereference a value, the code above looks like valid C++ code
Dumb
so it could work differently
SR27
means i can use & in c for only passing variable address , can't make reference variable.
Sajid
Hello guys, Anyone works with multi agent conflict base search algorithm?
Hizmu(Vlad)
This depends on a lot of things. There is no one right answer. This depends on your code, your architecture and your Long Term Vision plans. Basically you want a mechanism to do error handling from the Account library. How you do this depends on what clients of this library expect from the chosen error handling mechanism. Are you intending to create an alternative for clients to do if a call to your library fails? Or is the error that you return from your library just a FYI that you expect the client to log and not be able to do much after that. If it is the former case, then designing an exception hierarchy would be a choice. If your organisation doesn't allow exceptions, then you can return a struct with as much information as possible to help the client recover or try alternatives. If it is the latter case then you can return a error string encapsulated in a DBError struct (this allows you the possibility of extending this struct in future). (Look at std::expected. This class is like EitherOr in Functional programming languages that aids with better error handling mechanisms. It is available only in C++23 but is easy to implement using C++14 itself. There are many implementations available). The client can log the error string (if it is not a library itself) or pass it on to upstream clients (if it is another library) to inform about the error or even wrap it in an exception. Again, like I said there is no one right answer and the choice depends on your needs and your future plans.
Thanks a lot. I think that my program will solve the problem by other methods, but if it cannot it should inform the user without throwing exceptions.
SR27
#include <stdio.h> int f1() { printf ("Geeks"); return 1;} int f2() { printf ("forGeeks"); return 1;} int main() { int p = f1() + f2(); return 0; }
SR27
When '+' Associativity is from left to right, why this program is ambiguous it should call f1 then f2.
Hussein
c
what are you trying to do with & ?
Hussein
in c there is no ‘&’ in variable declaration
adnanhossainme
Pointer assign
SR27
i wanted to know that can i use & to make reference variable and can i do swap(a,b);//function call swap(int &a,int &b)//function defination
adnanhossainme
Just swap direct. First store that value on another variable then change.
SR27
ok
adnanhossainme
    int me = 15;     int *P = &me; //pointer should be assign like this
Anonymous
Hi All, I have created a stack template class I have included the header file in main.cpp but it gives me error as undefined reference to every function I use from stack class. Please let me know what I am doing wrong here; https://www.onlinegdb.com/ESs9QrysS PS: if i include stack.cpp it works
Anonymous
Hi All, I have created a stack template class I have included the header file in main.cpp but it gives me error as undefined reference to every function I use from stack class. Please let me know what I am doing wrong here; https://www.onlinegdb.com/ESs9QrysS PS: if i include stack.cpp it works
You can't separate a template class across a header file and an implementation file. There are ways around this but require more effort The simplest way to fix this would be to move the contents of stack.cpp to stack.hpp
Anonymous
When '+' Associativity is from left to right, why this program is ambiguous it should call f1 then f2.
No. Associativity is different from order of execution. Associativity ensures that the result of F1() is added to the result of F2(). But it does not ensure that F1() is evaluated before F2(). A compiler can evaluate F2() and then evaluate F1() and then add the former result to the latter result.
Anonymous
Thanks for the quick answer but its still giving the same error 😐
Means you haven't done what was suggested. Can you share the godbolt link with the new changes?
Anonymous
Means you haven't done what was suggested. Can you share the godbolt link with the new changes?
I don't know how to use godbolt I have added the codes as #1 #2 and #3 https://godbolt.org/z/sjfPo5Pzc
Anonymous
I don't know how to use godbolt I have added the codes as #1 #2 and #3 https://godbolt.org/z/sjfPo5Pzc
Did you understand what I asked you to do in my previous message? I asked you to get rid of stack.cpp and put all its contents in stack.h instead. Templates dont work like normal classes. Template definitions must be visible at the time of instantiation. If they are not then you will get a linker error.
Anonymous
guys what are smart pointers?
Anonymous
could you provide also an example?
/
Hi i need to know a thing
/
how can i make like a gui library without using opengl
/
for example using syscalls
/
to display things
/
and how does for exemple the bios of a computer display things when you enter the settings
/
i think it is made in c too
/
but i dont think there are syscalls or opengl