Anonymous
&arr is a pointer to array which type is T (*)[n]
olli
which snippet are we talking about?
Anonymous
Sorry, if I'm wrong
Anonymous
I'm talking about this one
I was asking about the code I mentioned.
olli
U can try :)
#include <cstdio> void printArraySize(int * arr) { int size = sizeof(arr)/sizeof(arr[0]); printf("Size: %d\n", size); } int main() { int array[100]; printArraySize(array); } Output: 2
Anonymous
This one
There's no arr
olli
There's no arr
parameter to the funciton
Anonymous
parameter to the funciton
Ok, it's definitely a pointer
olli
is that 2?
On most system yes. It comes down to sizeof(void*) / sizeof(int)
Anonymous
I would use a std::array or a reference to array instead
Anonymous
Anonymous
It's c++ only
I didn't get "reference to array" meaning
Anonymous
template <std::size_t n> void my_func(int (&arr)[n])
Anonymous
It's a reference to array
Anonymous
With an arbitrary size n
Anonymous
okk. I've seen this but hated understanding it.
olli
And the size needs to be a known at compile time
Anonymous
And the size needs to be a known at compile time
Definitely It is "static" C-array
Anonymous
int n; cin>>n; int b = n-5; So, we call the value of b to be known at run-time. Right?
Anonymous
There are many other things in cpp that look like (arr)[n]. "Something like this". Can anyone put the link or what do we call the above thing?
Anonymous
I want to check this stuff.
Anonymous
Cppreference.com
what do we call this?
Anonymous
I mean what to search for?
Anonymous
Idk Got this with experience
klimi
nite
olli
There are many other things in cpp that look like (arr)[n]. "Something like this". Can anyone put the link or what do we call the above thing?
well in this case the parentheses have no effect. Often its related to pointer to functions or array references.
{CSA}
Hey
Anonymous
Hey
Wow there's C++ itself
{CSA}
Yeah
Emma Nexus
Hi
Emma Nexus
Sup
Emma Nexus
Im new here
Dima
Emma Nexus
Hahaha
Dima
Why
Mat
Stop bothering people
Anonymous
I am beginner to c plz tell me where to start..
Anonymous
Start
Pete
Why do I sometimes get random negative integers in a series of numbers?
Pete
I understand there must be some error but I’d like to know why it’s doing that first
Pete
Pete
fib sequence without using recursion
Liam
int overflow
Liam
search it.
Pete
towards about the 50th number itll start going negative
Pete
I will
Pete
should I store the number after a certain point? Is there a wy to avoid it
dont
The problem is with data type
dont
Use biggest data type
Liam
should I store the number after a certain point? Is there a wy to avoid it
Basically, the root of the problem is that you are trying to store a too-large integer into a int32_t variable.
dont
It won't be negative
Liam
try int64_t or uint64_t.
Liam
Or, you'll have to utilize std::string to implement a bigint class and related operators to store and manipulate arbitrarily large integers.
Pete
try int64_t or uint64_t.
I appreciate it 👍
Anonymous
how to write an rar format dexompressor by c/c++?
Anonymous
wget https://www.rarlab.com/rar/rarlinux-x64-5.5.0.tar.gz
Anonymous
how to write an rar format dexompressor by c/c++?
There are libs for this stuff Just google it
Marián
guys any ideas why is ifstream so slow?
Anonymous
guys any ideas why is ifstream so slow?
Well.. because it's I/O It's always slow
Marián
nope, my ifstream is extremfly slow maybe because i am reading the file by lines in while loop
Marián
i am trying to load 200000+ lines file
Marián
in c# i read all lines at once and that managed it in program memory
Marián
Again I/O is always slow
not this way, in c# i could load that file in matter of 2-3 seconds, here its about minute
Anonymous
i am trying to load 200000+ lines file
Especially with this much of data
Anonymous
how are you reading it?
︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎ ︎︎
Studio.h function?