the use of strings : Array Char « Data Type « C / ANSI-C






the use of strings

  
#include <iostream>
using namespace std;

int main( )
{
 char        szmode1[4],                // car
             szmode2[6];                // plane
 static char szmode3[5] = "ship";       // ship

 szmode1[0] = 'c';
 szmode1[1] = 'a';
 szmode1[2] = 'r';
 szmode1[3] = '\0';

 cout << "\n\n\tPlease enter the mode > plane ";
 cin >> szmode2;

 cout << szmode1 << "\n";
 cout << szmode2 << "\n";
 cout << szmode3 << "\n";

 return(0);
}
  
    
  








Related examples in the same category

1.Compute the total of a list of numbers
2.Tic-Tac-ToeTic-Tac-Toe
3.Output the address of char array
4.For loop a char array
5.A simple dictionaryA simple dictionary
6.For loop a char array using pointer
7.Char array: pointer and loop
8.Assign a value to an element inside a char array
9.Char array: assign value and loopChar array: assign value and loop
10.Loop and output a char array
11.how array addressing and pointer arithmetic are linkedhow array addressing and	pointer arithmetic are linked
12.Show how bitmapped graphics may be usedShow how bitmapped graphics may be used
13.contiguous array storage
14.verifying array initialization