Afficher un message
Vieux 16/10/2007, 19h11   #1
Alan Curry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Identifying variables: what process do you follow?

In article <53f61$4714c98e$4275d90a$21258@FUSE.NET>,
Kevin Walzer <kw@codebykevin.com> wrote:
>
>With C, such an approach doesn't seem practical. You need to identify
>some variables ahead of time just to have a program that will compile!
>So, I'm wondering what approach seasoned C programmers use for larger
>programs, i.e. ones larger than the simple single-function ones I'm
>learning from my C textbook. Is there a design process that identifies
>such things?


Most of us don't type the complete program in a single pass from beginning to
end. If you use an editor instead, you'll have the ability to go back and add
variable declarations. The Standard Text Editor (ed) is sufficient, but there
are even more ful editors available today, which actually make use of the
cursor positioning abilities of the terminal, enabling you to see the code as
you edit it!

With this modern wonder, the full-screen text editor, you may begin writing a
C function without including any local variable declarations. When you come
to a point where you need a local variable, instruct the editor to relocate
the cursor to the beginning of the function. This is often done by the
repeated use of a key labeled with an arrow pointing in an upwardly
direction, each press of which will cause the editor to respond by moving the
cursor onto the preceding line of your source code.

Having arrived at the beginning of the function, insert the declaration.
Locate the cursor movement key of opposing orientation to the one previously
employed. Press repeatedly until the return of the cursor to its starting
position is actualized.

Advanced users may find editor shortcuts for moving the cursor to the desired
locations with fewer keypresses.

.... Seriously, what are you editing with, "cat > file.c" ?

--
Alan Curry
pacman@world.std.com
  Réponse avec citation
 
Page generated in 0,05732 seconds with 9 queries