C - Compilation Error with pointers exercise | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

C - Compilation Error with pointers exercise

Hi everyone, I hope someone can help me with what's wrong in my code. I started an exercise on Pointers in C, based on the SoloLearn course. Everything works fine until I get to a certain point, then when I run the code I get a compilation error. This is my code: https://code.sololearn.com/c6gXqx0hjQSz/?ref=app If the code is run as is, it sucessfully returns a result that I expect. However, when I remove the comment on line 17, so that line is now included when running the code, I get the compilation error. I'm experiencing this error in the SoloLearn app (android) and Sololearn on the web. But if I run the same code in another editor (jdoodle, and others), it runs successfully. There are warnings from some of those editors, but the code still runs. Any help and advice will be greatly appreciated. Kind regards rynhardt

2nd Aug 2019, 8:50 PM
Rynhardt Du Plessis
Rynhardt Du Plessis - avatar
1 Antwort
+ 1
Hmm, that's interesting, I think it's due to the configuration of the playground. Probably running in a virtual machine or container etc. If you print the address as a pointer instead of a hex int, then it works. Change %x to %p. This explains some of the finer details of printing pointers. https://stackoverflow.com/questions/9053658/correct-format-specifier-to-print-pointer-or-address
2nd Aug 2019, 9:49 PM
Jared Bird
Jared Bird - avatar