+ 7
What happened to this code?
I was very innocently creating a pointer in C++ and iterating. Then I get this very strange result. Why? https://code.sololearn.com/cRPckMPoqv0f/?ref=app
6 Antworten
+ 12
Your for loop doesn't have a break condition so it just goes on and on and prints whatever is in the memory locations after *name. And no, C(++) doesn't stop you from doing that so it's your job as a programmer to prevent accessing the 10th, 100th or 1000th element of an array that has only 6 elements. If you don't, your program will likely just crash at some point or you risk data loss
+ 4
Infinite loop? Weird...
+ 4
When i remove the “++” after the “name” it works just fine.
Also this is weird. I feel like the playground has a protection to prevent sensitive data from leaking out, can someone explain me what is the “LIFE_BARRIER”? Is what i understand correct?
+ 2
Anthony Quick Like wouldn't it throw an error?
+ 2
You might have to specify where does the string end
https://code.sololearn.com/cFvYYLlENsif/?ref=app
+ 1
i have one question , Can I learn complete java with sololearn ???