Advertisement
metalx1000

GCC check if Strings Match

Aug 20th, 2018
910
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1. /*
  2.  *Copyright (C) 2018  Kris Occhipinti
  3.  *https://filmsbykris.com
  4.  *
  5.  *This program is free software: you can redistribute it and/or modify
  6.  *it under the terms of the GNU General Public License as published by
  7.  *the Free Software Foundation, either version 3 of the License, or
  8.  *(at your option) any later version.
  9.  *
  10.  *This program is distributed in the hope that it will be useful,
  11.  *but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *GNU General Public License for more details.
  14.  *
  15.  *You should have received a copy of the GNU General Public License
  16.  *along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18. #include <stdlib.h>
  19. #include <stdio.h>
  20. #include <string.h>
  21.  
  22. int main(int argc, const char * argv[]){
  23.   /* Create a place to store our results */
  24.   int result;
  25.  
  26.   /* Create two arrays to hold our data */
  27.   char string1[] = "TEST";
  28.   char string2[] = "TSET";
  29.  
  30.   /* Compare the two strings */
  31.   result = strcmp(string1, string2);
  32.  
  33.   /* If the two strings are the same */
  34.   if (result == 0){
  35.     printf("MATCH!!!\n");
  36.   }else{
  37.     printf("NO MATCH!!!\n");
  38.   }
  39.  
  40.   return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement