-2
Hello I’m having trouble developing an algorithm that reads a.txt file, fix the text and create the result in another output file. The read process should occur line by line, but the input file has the following syntax error. The input file has a problem where several lines are repeated strings from previous line, differentiating from only one character. The algorithm must have a function that compares the two strings return 0 if they are equal and 1 if a character is different. If more characters are different, return the number of different characters between them.
t
you
tes
test
test
exit: "test"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// cada linha não deverá ter mais que 1000 caractere//
int Comparar(char *s1, char *s2) {
int i, j;
while (*s1)
s1++;
while (*s2) {
*s1 = *s2;
s2++;
s1++;
}
*s1 = '\0';
}
int main(int argc, char *argv[]) {
char Linha[1000]
FILE *arquivo;
arquivo = fopen("entrada.txt", "r");
if (arquivo == NULL) {
printf("Nao foi possivel abrir o arquivo \n");
return 1;
}
while (fgets(Linha, 1000, arquivo) != NULL)
printf("%s", arquivo);
fclose(
if (argc != 3)
{
printf("\nExecute o programa da forma:\n");
return 0;
}
It seems to me you haven’t pasted your code fully and correctly.
– anonimo