[Courses] Re: [C] Beginner's Lesson Twelve: Simple Pointers
KWMelvin
kwmelvin at intrex.net
Sun Nov 17 08:28:23 EST 2002
On Sat, Nov 16, 2002 at 02:30:19AM -0500, Morgon Kanter wrote:
> >> Pointers can be used to get around the passing by value restriction
> And another, not-as-elegant-and-more-bug-prone way is by having the
> functions manipulate variables with a wider scope.
>
> Morgon
Yes, declaring all variables outside of main() makes them "global".
Global variables are in the realm of MS-BASIC, and is what their
whole culture is based on. It is the equivalent of every user
being "root": the source of all of Microsoft's security problems.
It takes more work to declare variables with scope and class.
It also takes a lot of time and patience to learn about pointers.
It seems to be a difficult subject for most beginners. I've been
writing a lot of little snippets that do different things, so I
can see what pointers do, and how they work. Sometimes I "cheat":
I have `dosemu' installed on a 20MB custom `hdimage' running DR-DOS;
and I run an old 16-bit DOS debugger called `Power C Trace'. With
PCTrace I can have up to four `windows' open at once, and step
through my source code in one window, while watching variables
change in another `window', and see the program output in yet
another `window'. I'm using this while learning to do the same
things with `gdb' (the GNU Debugger). I have a console-only system.
--
K
More information about the Courses
mailing list