Hi,
This is my code
This is supposed to tahe two strings in a char array and compare them cell by cell. If one cell is not equal to the other at the second array (a != b) the function should return 0. If the condition in the if statement never gonna be true, as the for loop finishes it will return1.
It always return 0.
? tnx
This is my code
Code:
#include <stdio.h>
#include <string.h>
int sig(char [], char []);
void main()
{
char a[30];
char b[30];
scanf("%s", &a);
scanf("%s", &b);
printf("%d\n",sig(a,b));
}
int sig(char a[], char b[])
{
int i;
for (i=0; strlen(a); i++)
{
if (a[i] != b[i])
return(0);
}
return(1);
}
This is supposed to tahe two strings in a char array and compare them cell by cell. If one cell is not equal to the other at the second array (a != b) the function should return 0. If the condition in the if statement never gonna be true, as the for loop finishes it will return1.
It always return 0.
? tnx