nikolas_serafini

Lista 4 - Exercício 27

Jun 24th, 2013
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {  
  6.     int i,counter = 0;
  7.     char firstName[50],secondName[50];
  8.    
  9.     printf("Entre com o primeiro nome :\n");
  10.     gets(firstName);
  11.     printf("Entre com o segundo nome :\n");
  12.     gets(secondName);
  13.  
  14.     for (i = 0; i < strlen(firstName); i++)
  15.     {
  16.         if (firstName[i] != secondName[i])
  17.         {
  18.             counter++;
  19.         }
  20.     }
  21.  
  22.     if (counter == 0)
  23.         printf("Nome iguais!\n");
  24.     else
  25.         printf("Nomes diferentes!\n");
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment