Strings and Pointer Arrays

Slides:



Advertisements
Similar presentations
Chapter 9 Pointers and Dynamic Arrays. Overview 9.1 Pointers 9.2 Dynamic Arrays.
Advertisements

Course Introduction Bryce Boe 2013/06/25 CS24, Summer 2013 C.
Pointers Discussion 5 Section Housekeeping HW 1 Issues Array Issues Exam 1 Questions? Submitting on Time!
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Characters and Strings Literals and Variables Dale Roberts,
Command line arguments. – main can take two arguments conventionally called argc and argv. – Information regarding command line arguments are passed to.
Course Introduction Bryce Boe 2013/09/30 CS24, Fall 2013.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Command Line Arguments.
19&20-2 Know how to declare pointer variables. Understand the & (address) and *(indirection) operators. Dynamic Memory Allocation Related Chapter: ABC.
1 Command-Line Processing In many operating systems, command-line options are allowed to input parameters to the program SomeProgram Param1 Param2 Param3.
University of Malta CSA2090: Lecture 4 © Chris Staff 1 of 20 CSA2090: Systems Programming Introduction to C Dr. Christopher Staff.
CSE 232: C++ memory management Overview of Arrays Arrays are the simplest kind of data structure –One item right after another in memory (“contiguous range”
Lecture 5 functions 1 © by Pearson Education, Inc. All Rights Reserved.
Cryptography.
Fall 2004CS-183 Dr. Mark L. Hornick 1 C++ Arrays C++ (like Java) supports the concept of collections – mechanisms to sort and manipulate many instances.
Department of Electronic & Electrical Engineering IO reading and writing variables scanf printf format strings "%d %c %f"
Week 12 Methods for passing actual parameters to formal parameters.
Multi-dimensional Arrays and other Array Oddities Rudra Dutta CSC Spring 2007, Section 001.
Announcements You will receive your scores back for Assignment 2 this week. You will have an opportunity to correct your code and resubmit it for partial.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Characters and Strings Dale Roberts, Lecturer Computer Science,
Chapter 5 Pointers and Arrays Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh.
“Success consists of going from failure to failure without loss of enthusiasm.” Winston Churchill.
Week 6 - Friday.  What did we talk about last time?  Pointers  Passing values by reference.
Chapter 7 Process Environment Chien-Chung Shen CIS/UD
Parameter Passing: Arrays 1.Create new variables (boxes) for each of the formal parameters allocated on a fresh stack created for this function call. int.
Pointers and Classes.
Characters and Strings
Command Line Arguments
Command line arguments
Command Line Arguments
CMSC202 Computer Science II for Majors Lecture 08 – Overloaded Constructors Dr. Katherine Gibson Based on slides by Chris Marron at UMBC.
Command Line Arguments
CSE 303 Concepts and Tools for Software Development
CSC 253 Lecture 8.
Command-line Arguments
Command Line Parameters
CSC 253 Lecture 8.
Use proper case (ie Caps for the beginnings of words)
CS 240 – Lecture 18 Command-line Arguments, Typedef, Union, Bit Fields, Pointers to Functions.
Introduction to the Development of Personal Web Pages
Dale Roberts, Lecturer IUPUI
Manipulating File IO in Visual C++
Chapter 4 (part 2).
Understanding Program Address Space
Pointers Call-by-Reference CSCI 230
Subroutines – parameter passing
By Hector M Lugo-Cordero September 17, 2008
Topics discussed in this section:
The Problems in Using Visual C and Homework #2 Assignment
Introduction to Debugging Techniques in Visual C++ 6.0
CISC181 Introduction to Computer Science Dr
CS148 Introduction to Programming II
ECE 103 Engineering Programming Chapter 46 argc, argv, envp
CS149D Elements of Computer Science
C Programming Pointers
Building Windows Applications by Visual C++ and Homework #3 Assignment
Chapter 9: Pointers and String
Programming in C Pointers and Arrays.
Pointers and dynamic objects
Approximation Algorithms for the Selection of Robust Tag SNPs
Structure (i.e. struct) An structure creates a user defined data type
Functions Reasons Concepts Passing arguments to a function
Arrays and Pointers CSE 2031 Fall May 2019.
Characters and Strings
CSCE 206 Lab Structured Programming in C
Arrays and Pointers CSE 2031 Fall July 2019.
CS148 Introduction to Programming II
CS Problem Solving and Object Oriented Programming Spring 2019
Message Mapping Mechanisms in MFC and Other Applications in Visual C++
ENERGY 211 / CME 211 Lecture 29 December 3, 2008.
Presentation transcript:

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

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;

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]);

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 1:20.

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