🥰❤️😍
Can I get a good C++ PDF please
🥰❤️😍
Xudoyberdi
@itchannels
Xudoyberdi
Wojak
Wojak
Mastering and learning is different so please don't mention "By practising" because to reach the stage of practicing, one needs to know fundamentals or ground level basics
Igor🇺🇦
Mastering and learning is different so please don't mention "By practising" because to reach the stage of practicing, one needs to know fundamentals or ground level basics
Different people learn things differently. https://www.enotes.com/homework-help/why-there-no-one-best-teaching-method-398096
Anonymous
But in some cases
Anonymous
Getting rid of the goto might result in more complicated code
YVEF
Hi guys. If someone can help explain what's happening?! I have this code: byte* ptr_result = current_ptr - (impv_size + 1); some_struct* struct_info = reinterpret_cast<some_struct*>(ptr_result); if I debug over this two steps, the struct_info value is correct. but if just pass it without debug, the value is wrong. what is a dark magic? btw the structure is some_struct { DWORD, DWORD, DWORD, GUID }
YVEF
what's current_ptr and what is impv_size ? Otherwise one can only guess
current_ptr is also byte*, impv_size is size_t. current_ptr and of course result_ptr is just pointers to byte array
olli
current_ptr is also byte*, impv_size is size_t. current_ptr and of course result_ptr is just pointers to byte array
sure, but what's the context? What are the values? For all we know current_ptr could be a pointer into a struct containing an instance of some_struct and you want to get the address of that subobject. Similar to what CONTAINING_RECORD does [1].
christian
Anyone know where I could learn how to use git
Ammar
Anyone know where I could learn how to use git
https://www.google.com/search?q=learn+git
Alex
what is lock_guard for calling free function? I need free func to be called after function exits
Igor🇺🇦
what is lock_guard for calling free function? I need free func to be called after function exits
There is no need to lock on methods, only variables that can be updated from different threads.
Anonymous
Hi every one I need help regarding c++
Alex
There is no need to lock on methods, only variables that can be updated from different threads.
you don`t understand. void foo() { //code } I need free() to be called after foo exits(regular or exception). like mutex is unlocked in lock_guard
Igor🇺🇦
Alex
probably unique_ptr with custom deleter is an option.
Igor🇺🇦
probably unique_ptr with custom deleter is an option.
Are you using C++? Why are you using free in this case?
Alex
Are you using C++? Why are you using free in this case?
cause I have C API which is called from C++ code. C API returns allocated buffer. which I have to free
Alex
Igor🇺🇦
Alex
So you can use something like scope-guard with free in destructor
but I don`t have destructor. I have free func foo in which stdlib free() is called
Alex
ok, if you don`t have better idea, I will use unique_ptr with custom deleter
Igor🇺🇦
but I don`t have destructor. I have free func foo in which stdlib free() is called
https://en.wikibooks.org/wiki/More_C++_Idioms/Scope_Guard
Anonymous
You can use https://github.com/Neargye/scope_guard
Alex
https://en.wikibooks.org/wiki/More_C++_Idioms/Scope_Guard
why is it better than unique_ptr? unique_ptr is std lib
Igor🇺🇦
why is it better than unique_ptr? unique_ptr is std lib
You can add free in destructor. Unique_ptr calls delete
Anonymous
You can add free in destructor. Unique_ptr calls delete
You can provide custom deleter to smart pointers
Alex
You can add free in destructor. Unique_ptr calls delete
std::unique_ptr<char, decltype(&std::free)> t_copy { strdup(t), &std::free }; https://stackoverflow.com/questions/27440953/stdunique-ptr-for-c-functions-that-need-free
Igor🇺🇦
You can provide custom deleter to smart pointers
If that's more readable for you - use it. I'd prefer explicit class that cleans everything in a destructor. Whatever you prefer
Igor🇺🇦
Alex
thank you
Ammar
My approach void foo() { char *x = strdup(blah); try { // do something here.. } catch( ... ) { free(x); // Let someone higher up the call stack // handle it if they want throw; } free(x); }
Anonymous
It duplicates
Anonymous
And it's harder to maintain than RAII scope guard
Ammar
And it's harder to maintain than RAII scope guard
Thanks for the advice. I am not a C++ guy. But, I thought std::unique_ptr + lambda probably take more cycles on their construction.
Anonymous
Thanks for the advice. I am not a C++ guy. But, I thought std::unique_ptr + lambda probably take more cycles on their construction.
Well probably not Also do not make premature optimizations First you write good code and then optimize it if needed
Pavel
Hi every one I need help regarding c++
Hi, no need to ask meta questions like this (people don't answer those usually dontasktoask.com). Ask your question directly
KGF
Have any has data structure and algorithms in java , github directory , if any body had please share
Wisenky
which one runs faster for a huge N integer int a(unsigned int n) { if (n < 2) { printf("n: %d", n); return n; }; return a(n - 1) + a(n - 2); } int b(unsigned int n) { int fi = n, fi1prev = 1, fi2prev = 0; for (int i = 2; i <= n; i++) { printf("\nfi: %d", fi); fi = fi1prev + fi2prev; fi2prev = fi1prev; fi1prev = fi; } return fi; } how to understand this
Prince Of Persia
Hi I am looking for a dynamic Float in C++ like what we have in python like boost cpp_int
Anonymous
Make your btc ready
Vitalii
Sorry, I have a string like: val=5 val=3 val=4 val=10... How to read the numbers using strtok?(I have to put them into an array).
Prince Of Persia
are they in a string like this std::string str = "val=5 val=3 val=4 val=10..."
Vitalii
I mean that I have char array and I need to enter from the keyboard next string: value=5 value=4(and continue how much I want) after that put these values into int array
Prince Of Persia
C or C++?
Vitalii
C
Prince Of Persia
ok let me try
Vitalii
ok let me try
ohh, thanks for reviewing my problem
Prince Of Persia
btw you can do this in C++ int myArray[1000] = {}; for(int i = 0;std::cin >> myArray[i];i++); //here you have your all of your values in myArray
Prince Of Persia
but in c I guess you can change std::cin >> myArray[i] with scanf("%d",myArray[i]) idk maybe not work for scanf in C int myArray[1000] = {}; for(int i = 0;scanf("var=%d",&myArray[i]);i++); //here you have your all of your values in myArray
Prince Of Persia
another way is value control
Prince Of Persia
like you can do this
Prince Of Persia
int myArray[1000] = {}; for(int i = 0;i < 1000;i++){ int temp; scanf("var=%d",&temp); if(temp == -1){//or you can put any other value for controller break; } myArray[i] = temp; } //now myArray have all of your values
Prince Of Persia
I think it should be myArray+i, not myArray[I]
idk because int* pointer = &something; pointer+2 and pointer[2] are same
Igor🇺🇦
anyone know
There is multiprecision float according to this https://www.boost.org/doc/libs/1_75_0/libs/multiprecision/doc/html/index.html. Isn't that what you want?
Igor🇺🇦
idk because int* pointer = &something; pointer+2 and pointer[2] are same
Pointer + 2 is a pointer type, pointer[2] is a value type.
Prince Of Persia
btw I'm not a C programmer I'm programming in C++