4
The proposal is to create a program that compares n first positions of the two vectors and returns saying whether or not they are equal. So far so good, but I do not know how to ignore the case sensitive.
Here’s what I’ve done so far:
//Questão 7
#include <stdio.h>
#define MAX 5
int memcpy(char s1[], char s2[], int n);
int main()
{
char s1_m[MAX]={'a', 'b', 'c', 'd', 'e'}, s2_m[MAX]={'a', 'b', 'c', 'D', 'E'};
int n_m;
printf("quantos caracteres serao verificados(max 5)\n> "); scanf("%d", &n_m); fflush(stdin);
printf("os %d primeiros caracteres dos dois vetores %s iguais", n_m, memcpy(s1_m, s2_m, n_m)?"sao":"nao sao");
return 0;
}
int memcpy(char s1[], char s2[], int n)
{
int i, contador=0;
for(i=0;i<n;i++)
{
if(s1[i]==s2[i])
contador++;
else
break;
}
if(contador==n)
i=1;
else
i=0;
return i;
}
Did the posted answer solve your problem? Do you think you can accept it? If you don’t know how to do it, check out [tour]. This would help a lot to indicate that the solution presented was useful to you and to give an indication that it is satisfactory. You can also vote on any and all questions or answers you find useful on the entire site. Accepting and voting are separate things.
– Maniero