Baixe o app para aproveitar ainda mais
Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original
/* * File: main.cpp * Author: joao * * Created on 30 de Março de 2016, 01:36 */ #include <cstdlib> #include <cstdio> #include <string.h> #include <iosfwd> using namespace std; char FileCompare(char fileOne[], char fileTwo[]) { FILE *fileIn = fopen(fileOne, "r"); FILE *fileAux = fopen(fileTwo, "r"); char flag = '0'; char read[80]; char readOne[80]; do { fgets(read, 80, fileIn); fgets(readOne, 80, fileAux); if (strcmp(read, readOne) != 0) flag = '1'; } while (read != NULL && !flag); fclose(fileIn); fclose(fileAux); return (flag == '0'); } /* * */ int main(int argc, char** argv) { char nomeArq[40], nomeArq1[40]; //strcpy(nomeArq, "/home/joao/NetBeansProjects/Teste/estadoCid.slq"); //strcpy(nomeArq1, "/home/joao/NetBeansProjects/Teste/estadoCid1.slq"); printf("Digite o nome do arquivo 1:\n"); fflush(stdin); gets(nomeArq); printf("Digite o nome do arquivo 2:\n"); fflush(stdin); gets(nomeArq); (FileCompare(nomeArq, nomeArq1)) ? printf("\nSao Iguais") : printf("\nNao Sao Iguais"); return 0; }
Compartilhar