What Does the Program Do: char array based string - C++ Data Type

C++ examples for Data Type:char array

Description

What Does the Program Do: char array based string

Demo Code

#include <iostream> 
using namespace std; 

bool mystery3( const char *, const char * ); // prototype 

int main() //from  ww  w .java 2  s.  c  om
{ 
   char string1[ 80 ], string2[ 80 ]; 

   cout << "Enter two strings: "; 
   cin >> string1 >> string2; 
   cout << "The result is " << mystery3( string1, string2 ) << endl; 
   
}

bool mystery3( const char *s1, const char *s2 ) { 
   for ( ; *s1 != '\0' && *s2 != '\0'; ++s1, ++s2 ) 
       if ( *s1 != *s2 ) 
           return false; 

   return true; 
}

Result


Related Tutorials