Definition type

Jackson Marie (450)
In short, I have no idea...
Which way is faster?
1
2
3
Func(char *str, double d, int len, bool bExtra)
Func(char str[],double d, short len, bool bExtra)
Func(char str[], double *d, short len, bool bExtra);
Last edited on
vlad from moscow (3105)
There is no difference between the parameter declarations

char *str and char str[] because an array declared as passed by value implicitly is converted to a pointer to its first element. So these two declarations are equivalent.

As for double and double * then double * adds additional indirect access that requires more mashine commands. As for int and short then short usually is promoted to int. So it is better to use int.
Registered users can post here. Sign in or register to post.