Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 804 Vote(s) - 3.55 Average
  • 1
  • 2
  • 3
  • 4
  • 5
When initializing a char array, is the remaining space zero filled or uninitialized?

#1
Given

char foo[1024] = "bar";

This will initialize foo to contain 'b','a','r',0 . Is the remaining 1020 characters zero initialized, or uninitialized ?

I'd think the above is the same as `char foo[1024] = {'b','a','r','\0'} ; and as with initializing of aggregates, any member not mentioned is initialized to zero ?
Reply

#2
If an array/aggregate is initialized somehow[edit: by use of a static initializer], the remaining unspecified entries are zeroed, yes.
Reply

#3
Yes, the uninitialized array elements will be zeroes. Example:

If the initializer supplies too few elements, 0 is assumed for the remaining array elements:

int v5[8] = { 1 , 2 , 3 , 4 };

is equivalent to

int v5[] = { 1 , 2 , 3 , 4 , 0 , 0 , 0 , 0 };
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through