Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pointer Initalization

Tags:

c++

pointers

In the Code below:

char data[128] = "Just A Test \0";
char *cTest2 = data;
char *cTest3 = &data[0];

What is the difference between cTest2 and cTest3? When would you use one method of initialization over the other?

like image 844
user2155429 Avatar asked Feb 10 '23 14:02

user2155429


1 Answers

There is no difference; since a decent compiler would yield the same code, which you use would be according to personal preference.

like image 125
Scott Hunter Avatar answered Feb 12 '23 03:02

Scott Hunter