Pavel
The Out put is 1 2 2 3, how it is happened ?
Standard operators && and || use short-circuit evaluation, meaning that expressions on the right will be executed only if expression on the left is not enough to determine the final expression result if (true || a.isUserExist()) In this case for example the function will never be called
⚔️Mm⚔️ 🚫
The Out put is 1 2 2 3, how it is happened ?
Maybe your operation was true. What was the input?
⚔️Mm⚔️ 🚫
Anonymous
Please suggest me any best youtube channel for learning c programing
Bl
I don't get u
It was the c source code I typed and the output was this 1 2 2 3. I'm asking how this is happened. What's the logic ? Why use | | between that variable?
Pavel
It was the c source code I typed and the output was this 1 2 2 3. I'm asking how this is happened. What's the logic ? Why use | | between that variable?
|| is "logical OR" operator (you can google what it means) Also here are the docs: https://en.cppreference.com/w/cpp/language/operator_logical
Bl
|| is "logical OR" operator (you can google what it means) Also here are the docs: https://en.cppreference.com/w/cpp/language/operator_logical
I know that gate brother, but considering that code I'm asking how that variable changed to 1 2 2 3.
pavel
| is binary operator
⚔️Mm⚔️ 🚫
It was the c source code I typed and the output was this 1 2 2 3. I'm asking how this is happened. What's the logic ? Why use | | between that variable?
OK the || operator evaluates the statement that you've imputed, if any of the statement is true it returns 1if both are False it goes 0 But I dont get where you got 3
Janus
Because I am developing a script for a game, and when using sleep, the game is pausing
You need to have a separate thread, which would sleep (std::this_thread::sleep_for) periodically and then signal other threads to do something.
Pavel
I know that gate brother, but considering that code I'm asking how that variable changed to 1 2 2 3.
I commented above, this is because short-circuit evaluation of operator ||
Pavel
How
if (A || B) When A is true, B is not evaluated, right? That's what short-circuit evaluation mean. So some of your preincrement operators not being executed because the left part evaluated to true already.
Bl
Oh
Thanks Mardia
⚔️Mm⚔️ 🚫
Pavel
Ahh gotcha, thanks brother 🙏 ❤
There are also other tricky parts in that code (like bool converted to 1 and preincrement itself), but I guess you've already found them
Don
i have a executable thats been built of cpp and cl files. This executable stops at a specific point without any error. How can I debug this and find the point in the source code at which the program stops?
Engineer
yea
clang or gcc? Makefile or CMake?
我是大娃
Hello everyone! I can set M_MMAP_THRESHOLD by using mallopt(), how can I get the value ?
Anonymous
Hello everyone! I can set M_MMAP_THRESHOLD by using mallopt(), how can I get the value ?
You can't. You just have to remember the value you set it to. There is no way to retrieve it as far as I know
Anonymous
https://github.com/StephanTLavavej/STL/wiki/Standard-Library-Modules-Bug-Bash
Anonymous
https://github.com/StephanTLavavej/STL/wiki/Standard-Library-Modules-Bug-Bash
Stephan Lavavej announces Microsoft's implementation of the C++23 feature import std. He is calling people to test this feature and report any bugs. A bug is one where code using header files has a behavior different from code importing modules.
/
help
/
how can i copy all files and folders from a directory to another
klimi
\Device\NUL
in c++ or just do it? (mv cp -r dir1 dir2)
cp sar, mv is moving or renaming
klimi
jeez, k
klimi
-r :)
thought it is so basic that i made so many f*ck ups :D
Kirillov
Try Dev c++
Haha, nice joke
Kirillov
Dev instead of VS
Thadeu
if I dont need to return a pointer but I need to use a function that needs it, is there any problem or compatibility issue creating char x[30]; and then passing it to the function casting like this? innercall( (char *)&x );
Thadeu
or... even more, wouldnt this be better than calling malloc and free?
Vlad
or... even more, wouldnt this be better than calling malloc and free?
malloc and free is needed when you don't know size of your buffer at compile time
Thadeu
thanks @zoid0x18. So this alleviates most of the time as I always using malloc to create the pointer to be used with sprintf. Looks like this way are 2 less system calls.
Sajjad
how can i set -Werror=nothing in cmake --build
/
i have another problem
/
i was trying to use threads but i get an error
/
i have wrote this thread first (test()); but it tells me has incomplete type thread
Vlad
Basically. Rule of thumb to never use malloc unless you really have to
So you either use it for cases when lifetime of an object is not trivial and you have to manually manage
Vlad
Or size is too large for the stack/size is dynamic and you can't preallocate(e.g say that 100 will be max numbers of elements there)
/
wait i think i understanded
/
it was because i have not included thread
/
i have a question
\Device\NUL
How much memory did you need actually ?
/
jobjectArray instrumentsArray = env -> NewObjectArray (( int32_t ) soundfont.instrumentsCount, instrumentClass, nullptr); for ( int i = 0; i != soundfont.instrumentsCount; i++ ) { Instrument * instr = &instruments.at ( i ); env -> SetObjectArrayElement(instrumentsArray, i, env -> NewObject ( instrumentClass, instrumentClassInit, env -> NewStringUTF ( instr -> name ), createJintArray( env, instr -> linked_samplesID ))); } /* * Create sample array */ jobjectArray samplesArray = env -> NewObjectArray (( int32_t ) soundfont.samplesCount, sampleClass, nullptr); for ( int i = 0; i != soundfont.samplesCount; i++ ) { Sample * sample = &samples.at ( i ); env -> SetObjectArrayElement ( samplesArray, i, env -> NewObject ( sampleClass, sampleClassInit, stringToJstring ( env, sample -> name ), ( jint ) sample -> loopStart, ( jint ) sample -> loopEnd, ( jint ) sample -> sampleRate, i )); } do i do well if i create a thread for each loop
Abramo
does anyone know how to extract a number from a file with the sscanf function and compare it to another number and, if greater I increase a variable but if smaller I do nothing (in C)?
Saro
does anyone know how to extract a number from a file with the sscanf function and compare it to another number and, if greater I increase a variable but if smaller I do nothing (in C)?
scanf reads from standard input, but there is another function called fscanf which takes as an argument file descriptor. You can open your file and using fscanf function read the number from it.
Anonymous
int a = 5; printf("%d %d %d", a, a++, ++a) Why does this give output 7 6 7?
k4leg
int a = 5; printf("%d %d %d", a, a++, ++a) Why does this give output 7 6 7?
The sequence of evaluation expressions in function call is undefined—the compiler is free to do whatever it wants. For instance, int a, b; a = 1; b = (a+=5) + (a*=2); on some compilers b = 24 ;)
Anonymous
int a = 5; printf("%d %d %d", a, a++, ++a) Why does this give output 7 6 7?
Run this with the -Wall flag If there's undefined behavior, don't try to understand why the program works a certain way
k4leg
How is that undefined?
Different compiles can implement this in different way. This is not described in the standard. Usually, compilers do unexpected behavior for the sake of optimization.
Anonymous
Which compiler do you use?
Was doing it on onlinegd website