Array2 C++


//C-Strings.cpp
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#include<cstring.h>

char header[] = "\n *** C Strings ***\n\n";
int main()
{
char hello[30] = "Hello ", name[20], message[80];
   cout << header << "Your first name : ";
   cin >> setw(20) >>name; //enter a word
   strcat(hello, name); //append the name
   cout << hello << endl;
   cin.sync();             //no previous input
   cout << "\nwhat is the message for today?"<<endl;
   cin.getline(message,80);   //enter a line with a
    //max 79 characters
if (strlen (message) > 0) //if strings leght is
   { //longer than 0
    for(int i=0; message[i] != '\0';++i)
      cout << message[i] << ' ' ; //output with
      cout << endl; //white spaces
}
   getch();
   return 0;
}

Comments

Popular posts from this blog

Animasi Lucu C++

Sistem Sensor dan Robotika

DDL Part II