« first day (1323 days earlier)      last day (1513 days later) » 

7:44 PM
please tell me if i have a pointer to an array of 5 elements of type inf like this int clasic[5] {1,2,3,4,5}; and then i'm declaring a int (*ptrToArray)[5]. ptrToArray = &clasic; . I expected sizeof(ptrToArray) to be 20 and sizeof(**ptrToArray)` to be 4, but they are viceversa
 
I find cdecl.org always useful, you can put "int (*ptrToArray)[5]" in there and then see why it would be 4(or 8)
 
yes but i dont understand how does this help me :)
like i told you that i know i want a pointer to my array. but its size is not what i expected
 
the size of a pointer is the same as any other pointer pretty much
 
oh so you say that i have a pointer
i see
 
7 messages moved from Lounge<C++>
 
7:50 PM
@PeterT
 
hm yeah, it's a little complicated. An array is implemented as pretty much just a pointer, and can easily be converted to a pointer, even implicitly. But conceptually an array is different for the language
 
so did i get wrong this picture?
 
int name[5];
int* name2= name;
//sizeof name and name2 is different
no, you're right that pretty much explains it
 
how can i know when its about one or another?
like in the early example if i would dereferentiate one time, i would see the entire array address
whereas outputing just the pointer's addres would guide me to the first element address
 
for my example name and name2 would have the same address, but for your code example you introduced another level of indirection
//you had something like this:
int name[5];
using arrptr = int(*)[5];
arrptr name3 = &name;
 
7:56 PM
ok
still dont get though
 
@CătălinaSîrbu this is why in general C++ prefers std::array or std::vector or std::span because they are a lot easier to deal with.
 
I think your picture pretty much describes it well, except your ptrToArray is another arrow pointing to "name"
 
even if conceptually they are the same underneath
 
int (*ptrToArr)[5], ptrToArr = &name. if I try to *ptrToArray[0] - ok. If I try *ptrToArray[1] - garbage values
 
@CătălinaSîrbu oh, the operator [] binds stronger
(*ptrToArray)[1] is probably what you wanted
 
8:01 PM
<3
thank you
@Mgetz i still want to understand this
i'm aware that i will also have to learn std array or vector but just let me understand this for the moment :)
 
ok ok :))
thank you!
 
yep those are just nicer ways to do this
 
9:01 PM
Hi all anyone here have any luck with Microsoft Access automation in .net Core 3.0?
 
@DanColgan this is a C++ channel?
 
I think most people just use normal C++ here, not C++-CLI, I think you'd find more help in C# channels
 
 
1 hour later…
10:21 PM
Anybody online?
 
nope
 
10:41 PM
oki
 

« first day (1323 days earlier)      last day (1513 days later) »