+ 4
+SoLvEd+ How to remove wrong approved quiz?
I have posted a quiz and now I believed my answer is not entirely correct. The breakdown : https://code.sololearn.com/cJ4rXBsdnwQs/?ref=app Thanks Omkar for bringing this issue into my attention : https://www.sololearn.com/post/80809/?ref=app
21 odpowiedzi
+ 6
Contact info@sololearn.com. I mean, you did answer to this question, but I guess your answer applied to quizzes which haven't been accepted yet?
https://www.sololearn.com/Discuss/1712971/?ref=app
+ 5
It only initializes the array to 0's if it's static or thread storage or use a {} that is smaller than the array itself, which it is neither in the quiz's case.
+ 5
int a[10]; // a contains garbage
static int a[10]; // static storage, a is all 0's
int a[10]{}; // aggregate initialization, a is all 0's
int a[10]{ 1,2,3 }; // same as previous, first 3 elements are 1, 2 and 3 and the rest is initialized with 0's
thread_local int a[10]; // thread storage, a is all 0's. This is C++ though, not sure the C equivalent.
+ 3
Hatsy Rei
It is an approved quiz.
Thanks for your answer. I will write to sololearn now.
+ 3
+ 3
~ swim ~
I think if you do {} on an aggregate type it's an aggregate initialization, like with int a[10]{};
list initialization is I think for those types that take an std::initializer_list in it's constructor.
Don't quote me on that, I'm not sure either.
Confusing for sure, but the C++ standard mentions aggregate initialization "N4594 § 8.5.1 [dcl.init.aggr]".
I know it's not C but it's probably the same there.
+ 2
Calviղ
At step of 3,
The array a is not initialized at a[8],
it must have displayed 0 when I submitted the quiz. However, it is displaying junk values on my device now.
While the key of non assignment is demonstrated, unstable result is wrong result.
+ 2
~ swim ~
What does "in global scope" mean?
+ 2
~ swim ~ it works too~ wow~ 👏👏👏
+ 1
Only for non standard C, it would not initialise unassigned values.
So with C standard, your quiz is still correct.
+ 1
Calviղ I see 36 printed in my code snippet, so sololearn C is non standard C?
+ 1
Dennis
Can you kindly furnish us with an example for static, thread storage and using {} respectively?
0
What's wrong? I think it's a correct answer.
0
According to this https://stackoverflow.com/a/32708288
C standard would initialise all unassigned arithmetic values to zeros.
0
Dennis you're right.