Presentation is loading. Please wait.

Presentation is loading. Please wait.

Strings and Pointer Arrays

Similar presentations


Presentation on theme: "Strings and Pointer Arrays"— Presentation transcript:

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. 2019/2/24

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[]) argv[0] <=> char* <=> a string; argv[1] <=> char* <=> 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”, argv[0]); fprintf(“%s\n”, argv[1]);

4 Final Project You have to join a group composed of 5 to 7 people.
Please hand in the list of group members and 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 1:20.

5 Outline of Lecture Today
Demo of your Homework #5. Please make sure your program is ready to execute. Reform the project groups.


Download ppt "Strings and Pointer Arrays"

Similar presentations


Ads by Google