krad99 0 Denunciar post Postado Junho 7, 2008 eu definitivamente nao tenho talento pra c++...preciso de ajuda mais uma vez...talvez seja algo pikeno...e eu nao estou vendo pq tow de cabeça quente...enfim desde jah eu pesso desculpas por gastar o tempo de vcs e vamo ao problema...ele roda tdo certo agora o char vem limpo....mas o char P q eh o parametro da funcao vai sujo tem mais como eu tow montando nao taw passando a linha...se tiver mais de 1 registro no arquivo o programa indoida..enfim se puderem me ajudar fikrei mto grato novamente...segue o codigo: CODE #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> #define tagpoa "<poltrona>" #define tagpof "</poltrona>" #define tagpaa "<passageiro>" #define tagpaf "</passageiro>" int continuar; int flag; FILE *parquivo; //ponteiro para arquivo void abre_arquivo() { if ((parquivo = fopen("aviao.txt","r+b"))== NULL) parquivo = fopen("aviao.txt","w+b"); } int procura(char p[20]){ int i,x; char textoArquivo[100]; char poltrona[100] = ""; char aux[2] = " "; char aux2[100] = ""; x = 10; for(i = 0;;i++){ if(fgets(textoArquivo, 100, parquivo) == NULL){ break; }else{ fgets(textoArquivo, 100, parquivo); //pega uma string de 100 caracteres while(textoArquivo[x] != '<'){ puts(textoArquivo); aux[0] = textoArquivo[x]; strcat(poltrona,aux); ++x; } if(strstr(poltrona,p)){ return 1; }else{ continue; } } return 0; } } void cadastrar(){ int ie; char entrada[30]; char entrada2[30]; printf("\n Cadastrar Novo Aluno\n\n"); printf("\n\tNome do Aluno.....: "); fgets(entrada, 30, stdin); printf("\n\tNome do Aluno.....: "); fgets(entrada2, 30, stdin); ie = procura(entrada2); printf("%d",ie); char aux_tagpoa[60] = tagpoa; char aux_tagpaa[60] = tagpaa; strcat(aux_tagpoa,entrada2); strcat(aux_tagpaa,entrada); strcat(aux_tagpoa,aux_tagpaa); strcat(aux_tagpoa,tagpaf); strcat(aux_tagpoa,tagpof); char *xml = aux_tagpoa; //printf("%-20s",xml); fseek(parquivo,0,SEEK_END); fwrite(xml,strlen(xml),1, parquivo); getch();} main(){ abre_arquivo(); cadastrar(); getch(); } Compartilhar este post Link para o post Compartilhar em outros sites
_Isis_ 202 Denunciar post Postado Junho 7, 2008 Aqui não executa nada. Compartilhar este post Link para o post Compartilhar em outros sites