Advertisement
ThaisAlmeida

lol

Aug 18th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. typedef struct{
  6. char rua[30];
  7. char bairro[20];
  8. int numerocasa;
  9. }endereco;
  10.  
  11. typedef struct{
  12. char nome[20];
  13. int CPFRG;
  14. int fone;
  15. char data;
  16. endereco endereco1;
  17. }DADOS;
  18.  
  19. void Cadastro(DADOS *dados){
  20.  
  21. FILE *arquivo;
  22.  
  23. arquivo = fopen("Clientes.arq","w");
  24.  
  25. while(!feof(arquivo)){
  26. printf("Digite o nome:\n");
  27. gets(dados->nome);
  28. printf("Digite o Rg ou o cpf:\n");
  29. scanf("%d", &dados->CPFRG);
  30. printf("Digite a rua:\n");
  31. gets(dados->endereco1.rua);
  32. printf("Digite o bairro:\n");
  33. gets(dados->endereco1.bairro);
  34. printf("Digite o numero da casa:\n");
  35. gets(dados->endereco1.numerocasa);
  36. printf("Digite a data de ativação:\n");
  37. gets(dados->data);
  38.  
  39. fwrite(dados,sizeof(DADOS),1,arquivo);
  40. }
  41.  
  42. }
  43.  
  44. int Pesquisa(DADOS *dados,FILE *arquivo, int fone){
  45. int i=0;
  46.  
  47. while(!feof(arquivo)){
  48. fread(dados,sizeof(DADOS),1,arquivo);
  49. if(dados->fone == fone){
  50. return(i);
  51. }else{
  52. return(0);
  53. }
  54. i++;
  55. }
  56.  
  57. }
  58.  
  59. void Imprimir(DADOS *dados,FILE *arquivo){
  60. while(!feof(arquivo)){
  61. fread(dados,sizeof(DADOS),1,arquivo)
  62. printf("%s",dados->nome);
  63.  
  64.  
  65.  
  66.  
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement