-
Couldn't load subscription status.
- Fork 22
Final project #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
CTLJ99
wants to merge
2
commits into
CPRO-Session1:master
Choose a base branch
from
CTLJ99:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Final project #21
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| Clarke Littlejohn | ||
|
|
||
|
|
||
| Online Bank Simulator | ||
|
|
||
| The Program would be similiar to the bank project done before but with more features. It would have the user to enter the username | ||
| Then it would search for that persons file after that they would have to enter the password. It would have a record | ||
| of when things were purchased. I would use structs as the basic why to setup an account. File I/O would be the main part of this as all of this | ||
| would be saved. Most of the thing would be using functions and FileI/O. i dont really see how loops would be that useful. | ||
|
|
||
| I am doing this because i have no other ideas also this is the best this i could think of that would help me get use to using FileI/O | ||
| which i see as one of the more important thinds. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Clarke Littlejohn | ||
|
|
||
| Half the code I had got deleted. It was an online banking simulator. The main purpose of it was that it was using FILE I/O. | ||
| I will be uploading two executables. The both will be semi functional. The first one was the one that was almost complete, | ||
| there were a coouple of keey things like deposit withdrawal and history that are not functional. Those should be rather easy to implement | ||
| as i would just read from the file then update the values then write to the file. The only important thing to know is that some of the commands are useless | ||
| and that the program is case sensitive. | ||
|
|
||
| The program was just a more complex banking program that we wrote before. It was going to save everything and all that. I didnt finish the commenting as I was going to go back and do that and i did not finish the tbank2.c as alot of the code was giving me seg faults and i forgot the code and how i fixed it. |
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,208 @@ | ||
| //Clarke Littlejohn | ||
| //I thought of a why to use loops as i was going to use recursive but it was causing | ||
| //things to be slower and amny bugs. Did not any thing useful for | ||
| #include<stdio.h> | ||
| #include<string.h> | ||
| #include <unistd.h> | ||
| #include<sys/stat.h> | ||
| #include<stdlib.h> | ||
|
|
||
| void cS() | ||
| { | ||
| int i=0; | ||
| for(;i<5;i++){ | ||
| printf("\n"); | ||
| } | ||
| } | ||
|
|
||
| typedef struct{ | ||
|
|
||
| float bal; | ||
| char fName[100]; | ||
| char lName[100]; | ||
| char Username[12]; | ||
| char password[100]; | ||
| }bankUser; | ||
|
|
||
| int signup(bankUser); | ||
| bankUser signin(bankUser); | ||
| void menu(int,bankUser); | ||
| void deposit(bankUser); | ||
| void withdraw(bankUser); | ||
| void transfer(); | ||
|
|
||
| char * concat(char *one, char *two){ | ||
| char a[(sizeof(one)+sizeof(two)-4)]; | ||
| int i=0; | ||
| while(*one!='\0'){ | ||
| a[i]=*one; | ||
| one++; | ||
| i++; | ||
| } | ||
| while(*two!='\0'){ | ||
| a[i]=*two; | ||
| two++; | ||
| i++; | ||
| } | ||
| a[i]='\0'; | ||
| one=a; | ||
| return one; | ||
| } | ||
| int init(); | ||
|
|
||
| void update(); | ||
|
|
||
| int main(){ | ||
| int i =0; | ||
| for(;i<45;i++){ | ||
| printf("\n"); | ||
| } | ||
| init(); | ||
| bankUser init; | ||
| menu(0,init); | ||
|
|
||
|
|
||
| return 0;} | ||
|
|
||
| int init(){ | ||
| FILE* setup = fopen("users.txt","r"); | ||
| if(setup==NULL){ | ||
| setup=fopen("users.txt","w"); | ||
| fclose(setup); | ||
| mkdir("./BANK",0700); | ||
| } | ||
| else | ||
| fclose(setup); | ||
| return 0; | ||
| } | ||
|
|
||
| bankUser signin(bankUser user){ | ||
| int i=1; | ||
| char input[100]; | ||
| char unCheck[11]; | ||
| char opnFldr[100]; | ||
| printf("\nEnter your username: "); | ||
| fgets(input,sizeof(input),stdin); | ||
| input[strlen(input)-1]='\0'; | ||
|
|
||
| strcpy(opnFldr,"./BANK/"); | ||
| strcpy(opnFldr,concat(opnFldr,input)); | ||
| strcpy(opnFldr,concat(opnFldr,"/account.txt")); | ||
|
|
||
|
|
||
| FILE* infile = fopen("users.txt","r"); | ||
| while(!feof(infile)){ | ||
| fscanf(infile,"%s",unCheck); | ||
| if(strcmp(unCheck,input)==0){ | ||
| i=0; | ||
| fclose(infile); | ||
| FILE* infile2 = fopen(opnFldr,"r"); | ||
| fscanf(infile2,"%s",input); | ||
| strcpy(user.fName,input); | ||
| fscanf(infile2,"%s",input); | ||
| strcpy(user.lName,input); | ||
| fscanf(infile2,"%s",input); | ||
| strcpy(user.password, getpass("Enter your password. ")); | ||
| while(strcmp(input,user.password)!=0) | ||
| { | ||
| strcpy(user.password, getpass("Invalid Password. Reenter your password or type quit to quit: ")); | ||
| if(strcmp(user.password,"quit")==0){ | ||
| strcpy(user.fName,"back"); | ||
| return user; | ||
| } | ||
| } | ||
| fclose(infile2); | ||
| return user; | ||
| } | ||
| } | ||
| if (i==1){ | ||
| printf("Username not found."); | ||
| strcpy(user.fName,"back"); | ||
| } | ||
| return user; | ||
| } | ||
|
|
||
| void deposit(bankUser user){ | ||
| cS(); | ||
| } | ||
|
|
||
|
|
||
| void withdraw(bankUser user){ | ||
| cS(); | ||
| } | ||
|
|
||
| void history(){ | ||
| cS(); | ||
| } | ||
|
|
||
| int signup(bankUser user){ | ||
|
|
||
| cS(); | ||
|
|
||
| char input[100]; | ||
| char name[100]; | ||
|
|
||
| char folderS[] = {"./BANK/"}; | ||
| char unCheck[12]; | ||
|
|
||
| char newline = '\n'; | ||
| FILE * infile= fopen("users.txt","r"); | ||
|
|
||
| printf("\nIf you didnt mean to sign up for an account type back.\nEnter a username that is no longer than ten characters: "); | ||
|
|
||
| fgets(input,sizeof(input),stdin); | ||
| input[strlen(input)-1]='\0'; | ||
|
|
||
| while(!(feof(infile))){ | ||
|
|
||
| fscanf(infile,"%s",unCheck); | ||
| if(strcmp("back",input)==0) | ||
| break; | ||
|
|
||
| if(strlen(input)>10){ | ||
| printf("\nYour username is too long."); | ||
| printf("\nIf you didnt mean to sign up for an account type back."); | ||
| printf("\nEnter a username that is no longer than ten characters: "); | ||
| fgets(input,sizeof(input),stdin); | ||
| input[strlen(input)-1]='\0'; | ||
| continue; | ||
| } | ||
| if(strcmp(input,unCheck)==0){ | ||
| printf("\nThat username is taken."); | ||
| printf("\nIf you didnt mean to sign up for an account type back."); | ||
| printf("\nEnter a username that is no longer than ten characters: "); | ||
| rewind(infile); | ||
| fgets(input,sizeof(input),stdin); | ||
| input[strlen(input)-1]='\0'; | ||
| continue; | ||
| } | ||
| } | ||
| fclose(infile); | ||
|
|
||
| if(strcmp("back",input)==0) | ||
| return 10; | ||
| strcpy(user.Username,input); | ||
| char * test="./BANK/"; | ||
| char * temp=concat(test,input); | ||
| char * temp2= concat(temp,"/account.txt"); | ||
|
|
||
| } | ||
|
|
||
| void menu(int i, bankUser user){ | ||
| char input[100]; | ||
| cS(); | ||
| printf("\n\n\tOnline Banking Simulator\n"); | ||
|
|
||
|
|
||
| printf("\nType signin to signin.\nType signup to signup.\n "); | ||
|
|
||
|
|
||
| fgets(input,sizeof(input),stdin); | ||
| input[strlen(input)-1]='\0'; | ||
| if(strcmp(input,"signin")==0) | ||
| signin(user); | ||
| else if(strcmp(input,"signup")==0) | ||
| signup(user); | ||
|
|
||
|
|
||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please figure out a way to incorporate loops!