I am trying to learn C. Since I am already a little familiar with higher-level languages (PHP, Javascript, Python), I feel that most of my work involves learning how to replace structures that I would give for granted (e.g. arrays with variable size) using pointers and manual memory management. My problem is that I'm a little worried about playing with pointers.
I usually try to experiment with other language functions, but my problem is that poor use of pointers can lead to unexpected results. In particular: is it possible, if I am mistaken, that I can damage the memory segments that are used by other programs, which makes these programs behave badly? Or does the operating system (in my case various Ubuntu variants) prevent me from integrating with the memory allocated for different processes?
In the first case, I assume that it would be possible (albeit unlikely) that I can force other programs to write bad data to disk, distorting some of the information that I have on the hard drive. Or even the worst (and, even more unlikely, I think), it can damage some hardware - for example, older monitors can be burned by software that would set the refresh rate out of range.
I know that probably my worries are not justified, but I would like to know how far the compiler / operating system prevents me from doing dangerous operations when I make mistakes while manipulating pointers.
source
share