Hello.
There are source codes from 1 to 3 as shown below.
Which is the better way to initialize, number 1 or number 2?
And if you initialize it as duplicate(?) like number 3, there is no error in the build, is it the wrong code on the source code?
1. Initialize after declaring structure pointer
int main
{
struct Person p1;
struct Person *ptr;
ptr = &p1;
}
2. Initialize at the same time as the structure pointer declaration.
int main
{
struct Person p1;
struct Person *ptr = &p1;
}
3. Initialize redundancy(?)
int main
{
struct Person p1;
struct Person *ptr = &p1;
ptr = &p1;
}
Thank you.
struct pointer
Initialization in the second way is good for readability and performance. Number 3 doesn't have a problem with actual movements, but it seems to be a code that doesn't have to be used like that.
© 2024 OneMinuteCode. All rights reserved.