Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <fcntl.h>
- #include <string.h>
- #include <sys/stat.h>
- //Global variables
- char message[BUFSIZ];
- char option[BUFSIZ];
- // Declaration of functions
- void firstmenu();
- void loginserver();
- void adduser();
- void mainmenu();
- //Menus
- void firstmenu() {
- char answer;
- system("clear");
- printf("Welcome to Message Chat!\n\n");
- printf("This project was developed by:\n");
- printf("Helder Bessa up201503035@fc.up.pt 201503035\n");
- printf("Rafael Novais up201508010@fc.up.pt 201508010\n\n");
- printf("For more info read the README.txt file.\n\n");
- printf("\nDo you have an account?(y/n)\n");
- scanf( "%c" , &answer );
- if( answer == 'y'){
- system("clear");
- loginserver();
- }
- else if (answer == 'n') {
- system("clear");
- adduser();
- }
- else firstmenu();
- }
- void loginserver() {
- char username[80];
- system("clear");
- printf("Username:");
- scanf("%s" ,username);
- char *password = getpass("Password:");
- // check with server login information
- }
- void adduser() {
- char user[80];
- printf("Welcome to the sign up menu!\n\n");
- printf("Write a username that nobody is using and that you like.\n");
- printf("Username:");
- scanf("%s",user);
- // check with server if someone is using username
- printf("\nWrite a password\n");
- char *password = getpass("Password:");
- char *password2 = getpass("Confirm your password:");
- if (strcmp(password, password2)==0) {
- //check with server
- printf("The passwords match\n");
- }
- else {
- system("clear");
- printf("The passwords don't match!\n");
- adduser();
- }
- }
- void mainmenu() {
- char menuoption;
- system("clear");
- printf("----------Menu----------\n");
- printf("(1) List online users \n");
- printf("(2) Open chat \n");
- printf("(3) Change password \n");
- printf("(4) Logout \n");
- printf("(5) Quit \n");
- scanf("%c" ,&menuoption);
- switch(menuoption) {
- case '1' :
- break ;
- case '2':
- break;
- case '3':
- break;
- case '4':
- break;
- case '5':
- system("clear");
- exit(0);
- break;
- default :
- printf("Invalid option\n");
- mainmenu();
- }
- }
- int main() {
- firstmenu();
- }
Add Comment
Please, Sign In to add comment