Guest User

src

a guest
Apr 24th, 2019
76
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. // TO DO
  3. // VECTORI NETERMINATI
  4. int creare_cont();
  5. int creare_baza_date();
  6. int logare_cont();
  7. int verificare_robot();
  8. int baza_date;
  9. int i,n;
  10. struct date{
  11. char nume[32];
  12. char parola[32];
  13. int verificare;
  14. };
  15. struct date cont[20];
  16. void main(){
  17. int cont_nou_vechi;
  18. FILE *baza_date;
  19. baza_date = fopen("baza de date.txt", "r+");
  20. if (!baza_date){
  21. creare_baza_date();
  22. }
  23. printf("\nLogare (1) sau inregistrare (2) :");
  24. scanf("%d", &cont_nou_vechi);
  25. switch (cont_nou_vechi){
  26. case 1:
  27. logare_cont();
  28. break;
  29. case 2:
  30. creare_cont();
  31. break;
  32. default:
  33. printf("Valoare gresita! Terminare.");
  34. break;
  35. }
  36. }
  37.  
  38. int logare_cont(){
  39. i=0;
  40. printf("Nume: ");
  41. scanf("%s", &cont[1].nume);
  42. printf("Parola: ");
  43. scanf("%s", &cont[1].parola);
  44. fprintf(baza_date, "%s %s %d", cont[1].nume, cont[1].parola, &cont[1].verificare);
  45. verificare_robot();
  46. return 1;
  47. }
  48.  
  49. int creare_cont(){
  50. int i=0;
  51. printf("Nume: ");
  52. scanf("%s", &cont[1].nume);
  53. printf("Parola: ");
  54. scanf("%s", &cont[1].parola);
  55. verificare_robot();
  56. printf("***"); //DEBUG
  57. return 1;
  58. }
  59.  
  60. int creare_baza_date(){
  61. int x=0;
  62. printf("Baza de date inexistenta\nDoresti sa initializezi una? (1 - da; 0 - nu): ");
  63. scanf("%d", &x);
  64. switch (x) {
  65. case 0:
  66. printf("Program terminat! (baza de date inexistenta)");
  67. break;
  68. return 0;
  69. case 1:
  70. //creare baza date
  71. baza_date = fopen("baza de date.txt", "w");
  72. printf("Baza de date a fost creata!");
  73. break;
  74. default:
  75. printf("Valoare gresita");
  76. break;
  77. }
  78. return 1;
  79. }
  80.  
  81. int verificare_robot(){
  82. printf("Esti robot? (1+1): ");
  83. scanf("%d", &cont[1].verificare);
  84. for(i=0;i>n;i++){
  85. if (cont[1].verificare == 2){
  86. fprintf(baza_date, "%s %s %d", cont[1].nume, cont[1].parola, &cont[1].verificare);
  87. printf("Contul a fost creat cu numele: %s", cont[1].nume);
  88. } else {
  89. printf("Verificarea a esuat.");
  90. return 0;
  91. }}
  92. return cont[1].verificare;
  93. }
RAW Paste Data