Treating character arrays as strings. : char array « Data Types « C++ Tutorial

Home
C++ Tutorial
1.Language Basics
2.Data Types
3.Operators statements
4.Array
5.Development
6.Exceptions
7.Function
8.Structure
9.Class
10.Operator Overloading
11.Pointer
12.File Stream
13.template
14.STL Introduction
15.string
16.vector
17.list
18.bitset
19.set multiset
20.valarray
21.queue stack
22.deque
23.map multimap
24.STL Algorithms Modifying sequence operations
25.STL Algorithms Non modifying sequence operations
26.STL Algorithms Binary search
27.STL Algorithms Sorting
28.STL Algorithms Merge
29.STL Algorithms Min Max
30.STL Algorithms Iterator
31.STL Algorithms Heap
32.STL Algorithms Helper
C / ANSI-C
C Tutorial
C++
Visual C++ .NET
C++ Tutorial » Data Types » char array 
2.20.3.Treating character arrays as strings.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

int main()
{
   char string120 ]
   char string2[] "string literal"

   cout << "Enter the string: ";
   cin >> string1; 

   cout << "string1 is: " << string1 << "\nstring2 is: " << string2;

    for int i = 0; string1!= '\0'; i++ )
      cout << string1<< ' ';

   cin >> string1; 
   cout << "\nstring1 is: " << string1 << endl;

   return 0
}
Enter the string: string
string1 is: string
string2 is: string literals t r i n g
string

string1 is: string
2.20.char array
2.20.1.char array buffers
2.20.2.initialized string
2.20.3.Treating character arrays as strings.
2.20.4.Get line with buffer size for char array reading
2.20.5.Use cin.get() to read a string based on char array
2.20.6.Reverse case using array indexing.
2.20.7.Reverse a string in place.
2.20.8.Copying a string using array notation
2.20.9.Copying a string using pointer notation
2.20.10.Initializing char pointers with strings
2.20.11.Using an array of pointers to char
2.20.12.simple string variable
2.20.13.reads multiple lines, terminates on '$' character
2.20.14.reads string with embedded blanks
2.20.15.Read from keyboard and output char array
2.20.16.multidimensional char arrays
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.