Giáo trình C++ - Ngành CNTT - Part 08

92 857 0
Giáo trình C++ - Ngành CNTT - Part 08

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... Education, Inc Publishing as Pearson Addison-Wesley Slide 8- 19 Display 8.1 (1/2) Copyright © 2007 Pearson Education, Inc Publishing as Pearson Addison-Wesley Back Next Slide 8- 20 Display 8.1 (2/2) Copyright © 2007 Pearson Education, Inc Publishing as Pearson Addison-Wesley Back Next Slide 8- 21 C-strings as Arguments and Parameters   C-string variables are arrays C-string arguments and parameters are... function changes the value of a C-string parameter, it is best to include a parameter for the declared size of the C-string  If a function does not change the value of a C-string parameter, the null character can detect the end of the string and no size argument is needed Copyright © 2007 Pearson Education, Inc Publishing as Pearson Addison-Wesley Slide 8- 22 C-string Output  C-strings can be output with... Addison-Wesley Slide 8- 15 == Alternative for C-strings  The = = operator does not work as expected with C-strings  The predefined function strcmp is used to compareC-string variables  Example: #include … if (strcmp(c_string1, c_string2)) cout . s[9] H i M o m ! ? ? C-string Details Slide 8- 7 Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C-string Declaration  To declare a C-string variable, use the. work with C-strings Slide 8- 13 Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Assignment of C-strings  A common method to assign a value to a C-string variable. needed by '' Slide 8- 8 Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Initializing a C-string  To initialize a C-string during declaration: char

Ngày đăng: 14/07/2014, 11:00

Mục lục

  • An Array Type for Strings

  • Don't Change '0'

  • Safer Processing of C-strings

  • A Problem With strcpy

  • A Solution for strcpy

  • strcmp's logic

  • C-strings as Arguments and Parameters

  • Reading an Entire Line

  • The Standard string Class

  • Mixing strings and C-strings

  • I/O With Class string

  • getline and Type string

  • Character Input With strings

  • Another Version of getline

  • getline Returns a Reference

  • Mixing cin >> and getline

  • Program Example: Palindrome Testing

  • Palindrome Testing: remove_punct

  • Palindrome Testing: The Program

  • string Objects to C-strings

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan