Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- typedef struct{
- char rua[30];
- char bairro[20];
- int numerocasa;
- }endereco;
- typedef struct{
- char nome[20];
- int CPFRG;
- int fone;
- char data;
- endereco endereco1;
- }DADOS;
- void Cadastro(DADOS *dados){
- FILE *arquivo;
- arquivo = fopen("Clientes.arq","w");
- while(!feof(arquivo)){
- printf("Digite o nome:\n");
- gets(dados->nome);
- printf("Digite o Rg ou o cpf:\n");
- scanf("%d", &dados->CPFRG);
- printf("Digite a rua:\n");
- gets(dados->endereco1.rua);
- printf("Digite o bairro:\n");
- gets(dados->endereco1.bairro);
- printf("Digite o numero da casa:\n");
- gets(dados->endereco1.numerocasa);
- printf("Digite a data de ativação:\n");
- gets(dados->data);
- fwrite(dados,sizeof(DADOS),1,arquivo);
- }
- }
- int Pesquisa(DADOS *dados,FILE *arquivo, int fone){
- int i=0;
- while(!feof(arquivo)){
- fread(dados,sizeof(DADOS),1,arquivo);
- if(dados->fone == fone){
- return(i);
- }else{
- return(0);
- }
- i++;
- }
- }
- void Imprimir(DADOS *dados,FILE *arquivo){
- while(!feof(arquivo)){
- fread(dados,sizeof(DADOS),1,arquivo)
- printf("%s",dados->nome);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement