BinaryByter
|= is the same as c = c | 2;
BinaryByter
| is the "bitwise or" operator
I_Interface
BinaryByter
sure 😊
🐰🐾 سمیه
if c is 0, it will be 1 and 2 lol
I dunno why the programmer just hasn't assigned the values of 1 and 2 to c
BinaryByter
maybe he's on an architecture where logic gates are faster than assignments?
🐰🐾 سمیه
I don think so, it's a simple program
🐰🐾 سمیه
http://www.learntosolveit.com/cprogramming/Ex_5.14_sortrevnum.html
🐰🐾 سمیه
if you see any reason for that, please let me know
I_Interface
| is the "bitwise or" operator
forgot it, coz prefer to use C++)
BinaryByter
if you see any reason for that, please let me know
because or doesnt tamper with the current value of c
BinaryByter
yes I know
BinaryByter
and since you want to add many options
BinaryByter
and since you want to add many options
c will just add the option to the variable
BinaryByter
it will not set c to be the option
🐰🐾 سمیه
دنبال چی هستید؟
problem solved dear
MyDear
problem solved dear
چه مشکلی دارید؟
Mihail
چه مشکلی دارید؟
This chat is English only
BinaryByter
English only!
🐰🐾 سمیه
چه مشکلی دارید؟
I've a persian group, but that's a trash.
MyDear
problem solved dear
what your problem?
🐰🐾 سمیه
because or doesnt tamper with the current value of c
wait, but option is set to 1 or two, so its value changes
🐰🐾 سمیه
pv
I explained about the problem
BinaryByter
1 is 01 in binary
BinaryByter
2 | 1 = 11
O.
hi, advice me article about concurrent code on C11 please
🐰🐾 سمیه
true, so could you explain in detail why it hasn't just set option to 1 r 2 instead of using bitwise operator?
BinaryByter
what?
🐰🐾 سمیه
I mean we could simply set values of NUMBER or DEC to option
BinaryByter
No we couldn't
🐰🐾 سمیه
why using or operator
BinaryByter
because then we would overwrite other options
BinaryByter
if we have option one and two: your solution: options = 1 = 01 options = 2 = 10 end result: options = 2 My solution: options |= 1= 01 options |= 2 = 11 end result: options = 3
🐰🐾 سمیه
so it means our program may depend in option being 3, correct?
BinaryByter
No
BinaryByter
it just means that you fill the bits
BinaryByter
a bit like you would set different elements in an array
🐰🐾 سمیه
🐰🐾 سمیه
yes
BinaryByter
whats point in it?
that way we can store two things inside of one char
🐰🐾 سمیه
got a clue,. I'll read it in depth, if I don't undestand , I'll ask yo again. thanx
BinaryByter
#ot
🐰🐾 سمیه
is there anyone willing to give a long aswer?
🐰🐾 سمیه
🐰🐾 سمیه
🐰🐾 سمیه
these two programs are almost the same. one from the book, and one the prgrame we discussed
🐰🐾 سمیه
why in the book there are two functions, one for lexicographical sort, and one for numerical sort, but in the program we talked about there isn't any function for lexicographical sort and, and still it works for that purpose?
🐰🐾 سمیه
http://www.learntosolveit.com/cprogramming/Ex_5.14_sortrevnum.html
🐰🐾 سمیه
http://www.learntosolveit.com/cprogramming/Ex_5.14_sortrevnum.html
this is the link of the program without a function for lexicographical sort
S.
this is the link of the program without a function for lexicographical sort
not sure if you’re asking for the function pointer thing ...
S.
strcmp is a function from the library. numcmp is implemented somewhere in the source code
S.
one of them will be fed to qsort as a pointer to function
S.
that’s all ( so what’s the question?
🐰🐾 سمیه
one of them will be fed to qsort as a pointer to function
my qustion is, why in the program which I shared its link, there isn't any strcmp and still it works for that purpose?
S.
my qustion is, why in the program which I shared its link, there isn't any strcmp and still it works for that purpose?
the implementation/definition of strcmp is in the standard library, when you compile, and do the linking, the linker will find strcmp in the standard lib
S.
and the declaration of strcmp is in already in the header file string.h
S.
If you’re using gcc, then strcmp is in glibc
🐰🐾 سمیه
You misunderstood me
🐰🐾 سمیه
I'm saying that, there isn't any strcmp or any other function for that purpose in the second program
🐰🐾 سمیه
And why it still works for lexicographical sorting
Anonymous
/* numeric ? numcmp : strcmp if(numeric) numcmp; else strcmp; The program in the book has numeric value set to 0; So it's using string compare, But in the link you sent the numeric Value is set to 1 and the strcmp isn't even being used there. */
🐰🐾 سمیه
In this one there is strcmp
🐰🐾 سمیه
Anonymous
Read my text
Anonymous
Anonymous
#define numeric 1 /* numeric sort */ says it all
🐰🐾 سمیه
Yes
Anonymous
numcmp is comparing strings numerically it seems.
🐰🐾 سمیه
Why don't you get me 😫