Line 26: Line 26:
 
     however, at this time it must simply be known that "char * argv[]" is an array of arrays,
 
     however, at this time it must simply be known that "char * argv[]" is an array of arrays,
 
     which is also known as a two-dimensional array.
 
     which is also known as a two-dimensional array.
 +
 +
'''Q: If 'which ''<program_name>'' ' is typed in the terminal window, will the name of the current directory be returned?"
 +
    It should not.  If it does, then that is a security issue that must be resolved.
  
 
'''Q: Is an array initialized with size 20, really only of size 19?'''
 
'''Q: Is an array initialized with size 20, really only of size 19?'''

Revision as of 22:11, 16 January 2009

Lecture Questions

The following are some questions asked during class, followed by the professor's responses. The questions and answers have been paraphrased.


1/16/09, Friday

Q: "Where is the 'header file'?"

  The header file is within the #include<> statement.

Q: "Are the two parameters "argc" and "argv" required within the "main" function?"

  No, they are not required unless the programmer needs to use data which was typed in the same line as the execution of
  the program from the terminal window.
  Later on in the class, the main function may be defined as "int main()" or "int main(void)", and data may be retrieved
  from the user through the commands "scanf()" (see man scanf).
  *Note that the names "argc" and "argv" are a widely used convention, and changing their names is extremely discouraged.

Q: "Within the line,

int main(int argc, char * argv[])
{
  ...

What does the '*' between 'char' and 'argv[]' represent?"

   The '*' denotes a pointer.  Pointers will be discussed later on in the class,
   however, at this time it must simply be known that "char * argv[]" is an array of arrays,
   which is also known as a two-dimensional array.

Q: If 'which <program_name> ' is typed in the terminal window, will the name of the current directory be returned?"

   It should not.  If it does, then that is a security issue that must be resolved.

Q: Is an array initialized with size 20, really only of size 19?

   No.  Arrays begin with the index '0'; and although the last element may have index '19', the array is still of size '20'.

Q: Why is the '%s' specifier used within the printf() statement?

   The '%s' is the specifier to the printf() statement for a string (see man printf).

Alumni Liaison

Questions/answers with a recent ECE grad

Ryne Rayburn