Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  compara
Language: C/C++
Code:
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
int contar(char cadena[20]);
int main(){
//como saber si dos cadenas son iguales
char cad1[20],cad2[20];
int scad1,scad2;
int x=0,band;

printf("cadena1");
scanf("%s",&cad1);
printf("cadena2");
scanf("%s",&cad2);
scad1=contar(cad1);
scad2=contar(cad2);
if(scad1=scad2)
 { band=scad1;
   while( (cad1[x]==cad2[x]) && (band!=0))
   { x++;
     band--;}
   if(band==0)
   { printf("son iguales");}
   else
   { printf("son diferentes");}  
   return 0;
 }
 



 
}
int contar(char cadena[20]){
  int i;
  for(i=0;i<20;i++)
   { if(cadena[i]!='x0')
      { }
     else

       break;
    }

   return i;

 }

          
          
          
          
          
Comments: