Strings and Pointer Arrays - PowerPoint PPT Presentation

About This Presentation
Title:

Strings and Pointer Arrays

Description:

Strings and Pointer Arrays – PowerPoint PPT presentation

Number of Views:756
Avg rating:3.0/5.0
Slides: 6
Provided by: chi115
Category:
Tags: argv | arrays | pointer | strings

less

Transcript and Presenter's Notes

Title: Strings and Pointer Arrays


1
Strings and Pointer Arrays
  • Speaker Yao-Ting Huang
  • Advisor Kun-Mao Chao

National Taiwan University Department of Computer
Science Information Engineering Algorithms and
Computational Biology Lab.
2
Pointer Arrays (1/2)
  • A pointer variable contains the memory address
    where the actual value is stored.
  • char a declares a char pointer which points to
    the initial memory address of a string.
  • You can represent strings by arrays or pointers.
  • e.g., char n is the same as char n
  • An array of strings can be represented by an
    array of char pointers.
  • e.g., int main(int argc, char argv)
  • argv0 ltgt char ltgt a string
  • argv1 ltgt char ltgt a string

3
Pointer Arrays (2/2)
  • char argv is an array of char.
  • char argv is an array of strings.
  • When your program is invoked, the input arguments
    are passed to the main function as an array of
    strings.
  • e.g., C\Run parameter1 parameter2
  • char argv stores all the input arguments.
  • Since each array element is a char pointer (i.e.,
    a string), we can print each input argument by
  • fprintf(s\n, argv0)
  • fprintf(s\n, argv1)

4
Final Project
  • You have to join a group composed of 5 to 7
    people.
  • Please hand in the list of group members and
    email to both TA.
  • TAs will discuss with each individual group at
    12/9 and 12/23.
  • Each group should submit your proposal for final
    project by 12/2.
  • Each group should present your proposal at that
    day.
  • TA will correct your proposal in your
    presentation.
  • The students in both class A and class B should
    attend the class in PM 120.

5
Outline of Lecture Today
  • Demo of your Homework 5.
  • Please make sure your program is ready to
    execute.
  • Reform the project groups.
Write a Comment
User Comments (0)
About PowerShow.com