Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <curses.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. char login[24];
  5. char haslo[32];
  6. void odczyt(FILE *f)
  7. {
  8. char a;
  9. while(!feof(f)) {
  10. fscanf(f,"%c",&a);
  11. if(!feof(f))
  12. printf("%c",a);
  13. }
  14. void logowanie(FILE *f)
  15. {
  16.  
  17.  
  18. echo();
  19. printf("Podaj login \n");
  20. refresh();
  21. scanw("%[^\n]s",login);
  22. printw("Podaj haslo \n");
  23. refresh();
  24. noecho();
  25. scanw(" %[^\n]s",haslo);
  26. clear();
  27. printw("Zalogowano!");
  28. getch();
  29. endwin();
  30. fprintf(f,"%s\n %s\n ",login,haslo);
  31.  
  32. }
  33. int main()
  34. {
  35.  
  36. initscr();
  37. raw();
  38. WINDOW *w1;
  39. w1=newwin(LINES/2,COLS/2,LINES/2,COLS/2);
  40. wrefresh(w1);
  41.  
  42. FILE *plik;
  43.  
  44. plik = fopen(baza.txt","a+");
  45. if(plik == NULL) {
  46. printf("Błąd otwarcia pliku!\n");
  47. return 0;
  48. }
  49. logowanie(plik);
  50. if(fseek(plik,0,SEEK_SET)==-1) {
  51. printf("Błąd operacji przesuwania wskaźnika pliku!\n");
  52. return 0;
  53. }
  54. if(fclose(plik))
  55. printf("Błąd zamknięcia pliku!\n");
  56. return 0;
  57. }
  58. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement