Ir para conteúdo
Fórum Script Brasil

xandyrj

Membros
  • Total de itens

    11
  • Registro em

  • Última visita

Tudo que xandyrj postou

  1. Tarefa a ser executada: Retirar de um arquivo tagueado apenas o nome dos segurados (tag <NMSEG>), guardando-os em um outro arquivo. O formato do arquivo de saída é: uma lista numerada com os nomes dos segurados, um por cada linha. Ver exemplo abaixo: 1 - ANDRE GUIMARAES PEREIRA 2 - NATAL LUCIO
  2. Obrigado pela ajuda amigo,já consegui solucionar aki,mas mesmo assim obrigado.
  3. Preciso muito da ajuda de vocês...fui tentando aki e o resultado ainda não tá legal,segue abaixo o programa q etá dando erro. #include <string.h> #include <stdio.h> #include <stdlib.h> #include <conio.h> int main(void) { FILE *fp,*fb; char string [140]; char c; fp = fopen("REAL.DAT", "r+b"); if (fp == NULL) { printf("\nERRO na abertura do arquivo.\n"); exit(1); } fb = fopen ("real.saida","w+b"); if (fb==NULL) { printf("\nERRO no arquivo de saida.\n"); exit(1); } while ( c = fgetc (fp)!= EOF) { fgets (string,140,fp); if (fread(string,140,1,fp)!=1) { printf("\nERRO1\n"); //exit(1); } if (fwrite(string,140,1,fb) != 1) { printf("\nERRO2\n"); //exit(1); } if (fwrite("\r\n",2,1,fb )!=1) { printf("\nERRO3\n"); //exit(1); } } fclose(fp); fclose(fb); system ("pause"); }
  4. Amigos,peço uma ajuda urgente para conseguir colocar o while dentro desse programinha que criei aki no trabalho.Muito Obrigado. #include <string.h> #include <stdio.h> #include <stdlib.h> #include <conio.h> int main(void) { FILE *fp,*fb; char string [512]; fp = fopen("REAL.DAT", "r+b"); if (fp == NULL) { printf("\nERRO na abertura do arquivo.\n"); exit(1); } fb = fopen ("real.saida","w+b"); if (fb==NULL) { printf("\nERRO no arquivo de saida.\n"); exit(1); } if (fread(string,140,1,fp)!=1) { printf("\nERRO1\n"); //exit(1); } if (fwrite(string,140,1,fb) != 1) { printf("\nERRO2\n"); //exit(1); } if (fwrite("\r\n",2,1,fb )!=1) { printf("\nERRO3\n"); //exit(1); } fclose(fp); fclose(fb); system ("pause"); }
  5. xandyrj

    Numeros

    Muito Obrigado Pedro! ^_^
  6. xandyrj

    Numeros

    Bom dia...tenho uma lista de números e desejo desejo fazer um programa que leia essa lista e e compare com os numeros que eu digitei por exemplo vou digitar 3 numeros - 5-7-10 o programa vai me avisar em qual linha esses numeros estão 5-7-10 - 3 acertos 5-2-6 1 acerto 2-7-10 2 acertos podem me ajudar
  7. #include <string.h> #include <stdio.h> #include <stdlib.h> #include <conio.h> #define TAMMAXREG 500000 int main(void) { FILE *fp,*fb; char string [512]; int tamreg, tamarq; /* abrir o arquivo */ fp = fopen("DEMO.DAT", "r+b"); if (fp == NULL) { printf("\nERRO na abertura do arquivo.\n"); exit(1); } /* ler a string */ if (fgets(string, TAMMAXREG, fp) == NULL) { printf("\nERRO na leitura do arquivo.\n"); exit(1); } tamreg = strlen(string); if (fseek(fp, 0, SEEK_END) != 0) { printf("\nERRO no fseek.\n"); exit(1); } tamarq= ftell(fp); if (tamarq == -1) { printf("\nERRO no ftell.\n"); exit(1); } fb = fopen ("teste.saida","w+b"); if (fb==NULL) { printf("\nERRO no arquivo de saida.\n"); exit(1); } if (fseek(fp, 0, SEEK_SET) != 0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread(string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,5*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,1*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,6*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,2*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,7*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,3*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,8*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,4*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,9*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } /* display the string */ printf("tamreg = %d\n", tamreg); printf("registro = %s\n", string); printf("tamarq = %d\n", tamarq); fclose(fp); fclose(fb); getch(); }
  8. xandyrj

    Por Favor me ajudem

    #include <string.h> #include <stdio.h> #include <stdlib.h> #include <conio.h> #define TAMMAXREG 500000 int main(void) { FILE *fp,*fb; char string [512]; int tamreg, tamarq; /* abrir o arquivo */ fp = fopen("DEMO.DAT", "r+b"); if (fp == NULL) { printf("\nERRO na abertura do arquivo.\n"); exit(1); } /* ler a string */ if (fgets(string, TAMMAXREG, fp) == NULL) { printf("\nERRO na leitura do arquivo.\n"); exit(1); } tamreg = strlen(string); if (fseek(fp, 0, SEEK_END) != 0) { printf("\nERRO no fseek.\n"); exit(1); } tamarq= ftell(fp); if (tamarq == -1) { printf("\nERRO no ftell.\n"); exit(1); } fb = fopen ("teste.saida","w+b"); if (fb==NULL) { printf("\nERRO no arquivo de saida.\n"); exit(1); } if (fseek(fp, 0, SEEK_SET) != 0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread(string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,5*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,1*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,6*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,2*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,7*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,3*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,8*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,4*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fseek(fp,9*tamreg,SEEK_SET)!=0) { printf("\nERRO no fseek.\n"); exit(1); } if (fread (string,1,tamreg,fp)!=tamreg) { printf("\nERRO\n"); exit(1); } if (fwrite(string,1,tamreg,fb)!=tamreg) { printf("\nERRO\n"); exit(1); } /* display the string */ printf("tamreg = %d\n", tamreg); printf("registro = %s\n", string); printf("tamarq = %d\n", tamarq); fclose(fp); fclose(fb); getch(); } Aki está a solução...porém gostaria de colocar em Loop,alguém pode ajudar?
  9. xandyrj

    Por Favor me ajudem

    #include <string.h> #include <stdio.h> #include <stdlib.h> #include <conio.h> #define TAMMAXREG 500000 int main(void) { FILE *fp,*fb; char *string; int tamreg, tamarq; /* abrir o arquivo */ fp = fopen("DEMO.DAT", "r+b"); if (fp == NULL) { printf("\nERRO na abertura do arquivo.\n"); exit(1); } /* ler a string */ if (fgets(string, TAMMAXREG, fp) == NULL) { printf("\nERRO na leitura do arquivo.\n"); exit(1); } tamreg = strlen(string); if (fseek(fp, 0, SEEK_END) != 0) { printf("\nERRO no fseek.\n"); exit(1); } tamarq= ftell(fp); if (tamarq == -1) { printf("\nERRO no ftell.\n"); exit(1); } fb = fopen ("teste.saida","w+"); if (fb==NULL) { printf("\nERRO no arquivo de saida.\n"); exit(1); } if (fseek(fp,0,SEEK_SET) != 0); { printf("\nERRO no fseek.\n"); exit(1); } /* display the string */ printf("tamreg = %d\n", tamreg); printf("registro = %s\n", string); printf("tamarq = %d\n", tamarq); fclose(fp); getch(); } Porém ele ainda não está completo,agora tenho que saber como fazer para ler o primeiro registro e grava-lo no arquivo de saida
  10. Fazer um programa que lê um arquivo de dados, com registros de tamanho fixo e gera outro, intercalando o primeiro com o "metade + 1", o segundo com o "metade +2", o terceiro com o "metade + 3", .... Exemplo: Dado um arquivo de entrada com o conteúdo: 00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 O arquivo de saída deverá ficar: 00001 00006 00002 00007 00003 00008 00004 00009 00005 00010
×
×
  • Criar Novo...