Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #define MAXCHAR 16
- #define MAXADD 51
- #define MAXNAME 21
- #define MAXCODE 9
- #define MAXCART 100
- typedef char Char [MAXCHAR];
- typedef char Name [MAXNAME];
- typedef char Add [MAXADD];
- typedef char Code [MAXCODE];
- typedef char Adcd [MAXCODE];
- typedef struct {
- Name First;
- Name Second;
- Name Last;
- }sName;
- typedef struct {
- sName Userinfo;
- Add Address;
- }Userinfo;
- typedef struct {
- Code Prodcode;
- int qty;
- }ProductTag;
- typedef ProductTag arrBought[MAXCART];
- typedef struct {
- Char username;
- Char password;
- Userinfo info;
- char type;
- float credlimit;
- float outstanding;
- arrBought cart;
- int nItems;
- }Usertype;
- void getUserinfo (Userinfo *uInfo){
- printf("Enter your First Name: ");
- fgets(uInfo->Userinfo.First ,MAXNAME,stdin);
- printf("Enter your Middle Name: ");
- fgets(uInfo->Userinfo.Second,MAXNAME,stdin);
- printf("Enter your Last Name: ");
- fgets(uInfo->Userinfo.Last,MAXNAME,stdin);
- printf("Enter your Address: ");
- fgets(uInfo->Address,MAXADD,stdin);
- uInfo->Userinfo.Last[strlen(uInfo->Userinfo.Last)-1]='\0';
- uInfo->Userinfo.First[strlen(uInfo->Userinfo.First)-1]='\0';
- uInfo->Userinfo.Second[strlen(uInfo->Userinfo.Second)-1]='\0';
- if (uInfo->Userinfo.First[0] >= 97 && uInfo->Userinfo.First[0] <=122)
- uInfo->Userinfo.First[0]-=32;
- if (uInfo->Userinfo.Second[0] >= 97 && uInfo->Userinfo.Second[0] <=122)
- uInfo->Userinfo.Second[0]-=32;
- if (uInfo->Userinfo.Last[0] >= 97 && uInfo->Userinfo.Last[0] <=122)
- uInfo->Userinfo.Last[0]-=32;
- printf("Your Name is: ");
- printf("%s, %s %s\n",uInfo->Userinfo.Last,uInfo->Userinfo.First,uInfo->Userinfo.Second);
- printf("Your Address is: ");
- printf("%s\n",uInfo->Address);
- }
- void Signup (Usertype *user){
- char cDump;
- Adcd Admincode;
- do{
- printf("Enter Username: ");
- scanf("%s%c",user->username,&cDump);
- } while (strlen (user->username) < 3|| strlen(user->username) > 15);
- printf("%s\n",user->username);
- do{
- printf("Enter Password: ");
- scanf("%s%c",user->password,&cDump);
- } while (strlen (user->password) < 6|| strlen(user->password) > 15);
- printf("%s\n",user->password);
- getUserinfo (&user->info);
- printf("Enter account type: ");
- scanf("%c",&user->type);
- if (user->type=='s'|| user->type=='S'){
- user->credlimit = 5000.00;
- user->outstanding = 0.00;
- user->nItems = 0;
- }
- else if (user->type == 'a' || user->type == 'A'){
- printf("Enter Admin Code: \n");
- do{
- scanf("%s",&Admincode);
- if (strcmp(Admincode,"DLSZU2017")==0)
- user->type = 'A';
- } while (strcmp(Admincode,"DLSZU2017")!=0);
- }
- int main () {
- int exit=1,input;
- Usertype user;
- do {
- printf("Choose an option: \n");
- printf("Log-in : 1\n");
- printf("Sign-up : 2\n");
- printf("Exit : 3\n");
- scanf("%d",&input);
- switch (input){
- case 1:
- case 2: Signup (&user); break;
- case 3: printf("Exiting program\n"); exit=0; break;
- }
- } while (exit);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement