Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "StudentFunction.h"
- void CreateUser(struct User* userData)
- {
- printf("Choose your username ( max 64 characters and no space ): ");
- scanf("%s", userData->username);
- printf("Choose your password ( max 64 characters and no space ): ");
- scanf("%s", userData->password);
- printf("Your username is: %s \nYour password is: %s ", userData->username, userData->password);
- printf("\nyou account is created.");
- }
- int LogIn(struct User* userData, int numberOfUsers)
- {
- char username[64];
- char password[64];
- int a = 1;
- int check = 0;
- int position;
- for( int i = 0; i < numberOfUsers; i++)
- {
- printf("%s\t%s\n", userData[i].username, userData[i].password);
- }
- while (a == 1)
- {
- printf("\nEnter your Username: ");
- scanf("%s", &username);
- getchar();
- printf("\nEnter your Password: ");
- scanf("%s", &password);
- getchar();
- for (int i = 0; i < numberOfUsers; i++)
- {
- if ((strcmp(username, userData[i].username) != 0) || strcmp(password, userData[i].password) != 0)
- {
- }
- else
- {
- check = 1; // checkar om dom är lika med varandra.
- position = i; //vilken position användaren är på
- i = numberOfUsers;
- a = 0;
- printf("Login correct! ");
- }
- }
- }
- return position;
- }
- void StartMenu()
- {
- printf("\n MENU \n");
- printf("----------------\n");
- printf("1. Log In. \n");
- printf("2. Create user.\n");
- printf("3. Quit program. \n");
- }
- void MainMenu()
- {
- int choice = 1;
- while (choice != -1)
- {
- char newFileName[1000];
- char text[10000];
- char NewPass[64];
- FILE* PointerToFileText;
- PointerToFileText = fopen("Text.txt", "a+");
- printf("\n_______|MENU|__________\n");
- printf("\n");
- printf("1. Input your text \n");
- printf("2. Save your text to a new file \n");
- printf("3. Save your text in an already existing file \n");
- printf("4. Choose a file to read and present it's context \n");
- printf("5. Change your password\n");
- printf("6. log out \n");
- printf("7. exit program \n");
- printf("\nchoose a option: ");
- scanf("%d", &choice);
- getchar();
- switch (choice)
- {
- case 1:
- printf("Write your text: ");
- fgets(text, 1000, stdin);
- printf("%s", text);
- fputs(text, PointerToFileText);
- fclose(PointerToFileText);
- break;
- case 2:
- printf("\n%s\n", text);
- printf("\nEnter the name of your new file: ");
- scanf("%s", newFileName);
- FILE* PointerToNewFile = fopen("Text.txt", "a+"); // kommer behövas ändra när det kommer till att byta lösenord. Läser och skriver file, om det inte finns fil skapa en.
- fscanf(PointerToNewFile, "%d", &newFileName);
- getchar();
- fputs(text, PointerToNewFile);
- fclose(newFileName);
- break;
- case 3:
- printf("Name your already existing flie: ");
- case 4:
- printf("what file would you like to choose?: ");
- case 5:
- printf("Write your new password: ");
- case 6:
- printf("You are now logged out. ");
- StartMenu();
- choice = -1;
- break;
- case 7:
- exit(1);
- default:
- break;
- }
- //system("cls");
- }
- }
- //void Geneneratekey(char* Genkey, int* )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement