Advertisement
FuncaosCAndCPluplus

Strcmp_Function

Aug 16th, 2016
2,844
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <iostream>
  4. #include <string.h>  
  5.  
  6. using namespace std;
  7.  
  8.    
  9. int main() {
  10.    
  11.    
  12.     char name1[] = "AM";
  13.     char name2[] = "AMP";
  14.    
  15.     char name3[] = "AMP";
  16.      
  17.           // First name, is smaller than second!
  18.       if( strcmp(name1,name2) < 0){
  19.          cout<<"First name, is smaller than second!"<<endl;
  20.          
  21.      }
  22.      
  23.      cout<<endl;
  24.      
  25.          // second name, is larger than First name!
  26.      if( strcmp(name2,name1) > 0){
  27.          cout<<"second name, is larger than First name!"<<endl;
  28.          
  29.      }
  30.  
  31.      cout<<endl;
  32.      
  33.          // Are of same size
  34.      if( strcmp(name2,name3)  == 0){
  35.          cout<<"Are of same size"<<endl;
  36.          
  37.      }  
  38.        
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement