(New page: == 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 Q: "Where ...)
 
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
[[Category:ECE264Spring09lu]]
 +
[[Category:programming]]
 +
[[Category:C]]
  
== Lecture Questions ==
+
== [[ECE264]] Lecture Questions, Spring 2009, Prof. Lu ==
  
 
The following are some questions asked during class, followed by the professor's responses.  The questions and answers
 
The following are some questions asked during class, followed by the professor's responses.  The questions and answers
 
have been paraphrased.
 
have been paraphrased.
  
1/16/09
+
--------------------------------------------------------------------------------------------------------------------------
 +
== ''1/16/09, Friday'' ==
 +
'''Q: "Where is the 'header file'?"'''
 +
  The header file is within the #include<> statement.
  
Q: "Where is the 'header file'?"
+
'''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 commands such as "scanf()" (see ''man scanf'').
 +
  *Note that the names "argc" and "argv" are a widely used convention, and changing their names is extremely discouraged.
  
A: The header file is within the #include<> statement.
+
'''Q: "Within the line,'''
  
Q: "Are the two parameters "argc" and "argv" required within the "main" function?"
+
'''int main(int argc, char * argv[])'''
 
+
'''{'''
A: No, they are not required, unless the programmer needs to use data which was typed after the execution of the program.
+
'''  ...'''
  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,
+
'''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.
  
    int main(int argc, char * argv[])
+
'''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.
      ...
+
    }
+
  
     What does the '*' between 'char' and 'argv[]' represent?"
+
'''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'.
  
A: The '*' denotes a pointer. Pointers will be discussed later on in the class,
+
'''Q: Why is the '%s' specifier used within the printf() statement?'''
however, at this time it must simply be known that "char * argv[]" is an array of arrays,
+
    The '%s' is the specifier to the printf() statement for a string (see ''man printf'').
which is also known as a two-dimensional array.
+
----
 +
[[ECE264_%28YungluSpring2009%29|Back to ECE264 Spring 2009, Prof. Lu]]

Latest revision as of 05:39, 11 July 2012


ECE264 Lecture Questions, Spring 2009, Prof. Lu

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 commands such as "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).

Back to ECE264 Spring 2009, Prof. Lu

Alumni Liaison

Have a piece of advice for Purdue students? Share it through Rhea!

Alumni Liaison