j
thats the problem, definetely
Ariana
> size_t num_dates = sizeof dates / sizeof *dates; It doesn’t work for like dynamic arrays, I suggest replacing it with a length variable
j
but how do i get how many dt structs are there in my array
Ariana
loop through and count
Ariana
So you’ll have to initialize it first
Ariana
> size_t num_dates = sizeof dates / sizeof *dates; It doesn’t work for like dynamic arrays, I suggest replacing it with a length variable
for this just have len as a parameter or have a ‘exploding array’ struct with a len as a field
Shivam
Weird flex but ok
Ariana
wut
Ariana
Ive been hearing that so often but cant understand rip getting old XD
Ariana
my CS teacher was surprised I was able to check for graph isomorphism was a good idea to drop CS right after it started with python turtle
Shivam
Shivam
Dayum
j
if (cmp_dates((const void *d1)dates[o], after) == 1 && cmp_dates(dates[o], before)== -1){
j
trying to make that if statement work
j
with cmp_date being
j
int cmp_dates(const void *d1, const void *d2)
Ariana
huh
j
how do i cast my values to make it work?
Ariana
ok so you’re inputing const void * into a function
Ariana
and wanting what format?
j
im recycling the cmpare method i did for the qsort i used before
Ariana
So int?
j
ye
j
s
Ariana
*(int*)d1 or smt
j
but im not comparing int's
Ariana
cast it to int then dereference it
Ariana
.-.
j
im comparing dt structs
j
but input for the compare method has to be void so it works with qsort
Ariana
j
idk
j
they're in an array, does that make them ptrs
j
?
j
it does not, right?
Ariana
*(struct dt **)d1 smt like this?
j
yes
Ariana
Each element points to the location of the structure in the heap
j
so they are pointers
Ariana
Yes
j
int number[3] = {1, 2, 3}
j
would number[0] be a pointer?
Ariana
example(on a crappy iphone): double foo(struct Expr *n1,struct Expr *n2){ return (n1->val) - (n2->val); }
Ariana
So basically your function would take in a pointer, and like pointer->stuff will access the structure pointer member
Ariana
would number[0] be a pointer?
Over here ah yes if you want to torture people You can do *(number+i) instead of number[i]
j
n1->val-n2->val what does this mean
j
?
j
@Ariana1729
j
*(struct dt **)d1 smt like this?
but i think I have to cast to void
Ariana
are you trying to cast in in qsort or access it in function?
j
im not using qsort
Ariana
.-.
j
i used qsort previously
Ariana
If not then why bother casting to const void*
j
and now i want reutilize the cmpr method
Ariana
Just change it its better that way
Ariana
less confusion
j
which only accepts const void
j
what do i change?
Ariana
Uhhh just change the variable type?
Ariana
Like unless its a library
klimi
I'm admin
Ariana
Hi admin
Ariana
I’m kid
klimi
Hi maxis friend
Thespartann
Hi admin
Hi nonadmin
Thespartann
klimi
Ariana
j
@Ariana1729 i have it working
j
but not as expected
j
if (cmp_dates(&dates[o], &after) == 1 && cmp_dates(&dates[o], &before)== -1)
j
never evaluates
j
10/09/2012 03/02/1982 23/11/2018 30/04/2000
j
those are my dates