#include <iostream>
#include <math.h>
using namespace std;
int main()
{
// try replacing the declaration below
//with this one
//char x[]= {'a','b','c','d'};
//create a c string...the null terminator is automatically added
char x[10] ="abcd";
for(int i=0; x[i]!= '\0';i++){
cout <<"x["<<i<<"] : "<< x[i]<<endl;
}
cout<<"\n-Now with a While Loop-"<<endl;
int count= 0;
while(x[count] != '\0'){
cout <<"x["<<count<<"] : "<< x[count++]<<endl;
}
// Try uncommenting the lines below to see what happens
//x ="wxyz";
//
char y[10];
//char * strcpy ( char * destination, const char * source )
cout<<"\n-copy x to y-"<<endl;
strcpy(y,x);
count=0;
while(y[count] != '\0'){
cout <<"y["<<count<<"] : "<< y[count++]<<endl;
}
if(x==y)
cout<<"\nThey are equal"<<endl;
else
cout<<"\nThey are not equal"<<endl;
if(strcmp(x,y)==0)
cout<<"\n strcmp(x,y) is true"<<endl;
else
cout<<"\nstrcmp(x,y) is false"<<endl;
}