From 073c1adaa2ac6991e353479df8505ff9aef54321 Mon Sep 17 00:00:00 2001 From: julialaurentan Date: Mon, 11 Jul 2016 09:52:32 -0400 Subject: [PATCH 1/8] proposal --- proposal.txt | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 proposal.txt diff --git a/proposal.txt b/proposal.txt new file mode 100644 index 0000000..3837baa --- /dev/null +++ b/proposal.txt @@ -0,0 +1,53 @@ +Julia Tan + +1. what it is, what it does/does not do, what the game simulates +2. detailed examples of concept implementation +3. reasons for picking project + + +1. My program will simulate an app that acts as a directory to keep all the user's contacts in place. Unlike a regular contact book, this program would also be able to categorize contacts and add ratings. + +Functions of the program: +- Store contacts +- Categorize contacts into groups such as family, food, clothes +- Create categories +- Add and edit details to each contact, which are name, telephone number, ratings(for businesses especially), category and address +- Display a list of all the contacts under a category +- Display chosen contact's details + +What the program cannot do: +- Text and call + +2. Detailed Examples of Concept Implementation +Input +- takes in contact details from user i.e. name, telephone number, rating, address, category +- takes in category name from user +- takes in commands from user such as to display a list of all contacts in a category, display the chosen contact's details, or edit contact details + +Output +- displaying contact details +- displaying categories +- displaying contacts under a specific category + +Conditional Statements +- Processes user commands to see what they would like to do, such as create a contact, edit contact details, create new category, etc. + +Loops +- For loops to print out contents of a category + +Functions +- Function to add contact details to a category +- Function to create new category +- Function to finish program +- Function to display category contents +- Function to display contact details + +Arrays/strings +- Each category would be an array +- Each contact detail is a string + +Advanced data types: structs +- Each contact would be a struct that would contain name, address, telephone number, rating and category + +3. Reasons for picking this project +I chose to do this project because I wanted to create some kind of 'app' that someone could use on a phone. I also wanted to do something that could be quite useful, compared to games. From 7ae05ad7f547441faf676cb42184173cdb68eae9 Mon Sep 17 00:00:00 2001 From: julialaurentan Date: Mon, 11 Jul 2016 11:58:31 -0400 Subject: [PATCH 2/8] update --- proposal.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/proposal.txt b/proposal.txt index 3837baa..23f106e 100644 --- a/proposal.txt +++ b/proposal.txt @@ -1,10 +1,5 @@ Julia Tan -1. what it is, what it does/does not do, what the game simulates -2. detailed examples of concept implementation -3. reasons for picking project - - 1. My program will simulate an app that acts as a directory to keep all the user's contacts in place. Unlike a regular contact book, this program would also be able to categorize contacts and add ratings. Functions of the program: From 8896f8c600f027783ac2ddc0e733e22672de5338 Mon Sep 17 00:00:00 2001 From: julialaurentan Date: Fri, 15 Jul 2016 07:00:20 -0400 Subject: [PATCH 3/8] Julia Tan - Final Project --- ProjectREADME.txt | 13 ++++ contacts.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++ final | Bin 0 -> 13136 bytes 3 files changed, 187 insertions(+) create mode 100644 ProjectREADME.txt create mode 100644 contacts.c create mode 100755 final diff --git a/ProjectREADME.txt b/ProjectREADME.txt new file mode 100644 index 0000000..c12ab96 --- /dev/null +++ b/ProjectREADME.txt @@ -0,0 +1,13 @@ +Contact Book + +This is a contact book that is able to: +- create and store contacts +- add and edit details to each contact +- organize contacts into custom categories +- display contact information + +To navigate the application, use the number keys to select an option that is displayed. +All functions and instructions will be displayed on the screen. Enjoy! + +Julia Tan +July 15, 2016 diff --git a/contacts.c b/contacts.c new file mode 100644 index 0000000..e8389d0 --- /dev/null +++ b/contacts.c @@ -0,0 +1,174 @@ +// Julia Tan +// Final Project July 13, 2016 + +#include +#include + +typedef struct contact{ // Make a new contact + char name[100]; + int telnum; + char rating[4]; + char address[100]; +}newCon; + +typedef struct category{ + char cname[100]; + int contactCount; + newCon contact[50]; +}newCat; + +void userSelect(int* a); +void categories(int choice1); +void newContact(int categoryNum, newCat* category); + +void userSelect(int* a){ // Process what the user wants to do + scanf("%d", a); + int selected = 0; + if (*a == 1){ // Create a new contact + categories(1); + }else if (*a == 2){ // View categories + categories(2); + }else if (*a == 3){ // View contacs + categories(3); + }else if (*a == 4){ // Edit details + categories(4); + }else if (*a == 5){ // Exit + + }else{ + printf("Invalid selection. Please try again:\n"); + userSelect(a); + } +} + +void newContact(int categoryNum, newCat* category){ // Add a new contact + int *conCountPtr = &(category[categoryNum].contactCount); // Counts number of contacts within chosen category + char enter; // Checks for \n symbol + int phone; // evaluates scanf + // Create a new contact + printf("New Contact\n"); + printf("Enter full name: "); + scanf(" %[^\n]%*c", category[categoryNum].contact[*conCountPtr].name); + + do{ // gets phone number and makes sure it is only made of integers + printf("Enter phone number: "); + phone = scanf("%d%c", &category[categoryNum].contact[*conCountPtr].telnum, &enter); + if (phone != 2 || enter != '\n'){ + printf("Invalid number, try again.\n"); + while (getchar() != '\n') + ; + } + }while (phone != 2 || enter != '\n'); + + printf("Enter rating: "); + scanf(" %s", category[categoryNum].contact[*conCountPtr].rating); + + printf("Enter address: "); + scanf(" %[^\n]%*c", category[categoryNum].contact[*conCountPtr].address); + + printf("Contact successfully added.\n\n"); + (*conCountPtr)++; +} + +void categories(int choice1){ + static int catCount = 0; // counts number of existing categories + static newCat category[10]; // creates an array of categories + newCat *catPtr = category; // pointer to array of categories for functions + static int userIn = 0; // user input for what category they want to put their contacts in + int i = 0; // index for category array + int x = 0; // index for contacts array inside the contacts array + int *conCount = &category[i].contactCount; // pointer to number of contacts in array + int cat = 0; + int cont = 0; + int phone; + char enter; + + + if (choice1 == 1){ // Select a category to put your contact in + printf("\nSelect a category to put your new contact in:\n"); + printf("(0) Create a new category\n"); + categories(2); + scanf("%d", &userIn); // Create new category or choose existing + + while (userIn < 1){ + + if (userIn == 0){ // Creating a new category + catCount++; // Increases count of categories + printf("\nEnter name of new category: "); + scanf(" %[^\n]%*c", category[catCount].cname); // Renames new category + category[catCount].contactCount = 0; + printf("Category successfully created.\n\n"); + } + printf("\nSelect a category to put your new contact in:"); + printf("(0) Create a new category\n"); + categories(2); + scanf("%d", &userIn); + } + newContact(userIn, catPtr); // arg1 is number of categories, arg2 is pointer to category array + } else if (choice1 == 2){ // Print categories with contacts underneath + for (i = 1; i <= catCount; i++){ + printf("\n(%d) %s\n", i, category[i].cname); + for (x = 0; x < category[i].contactCount; x++){ + printf("- %d. %s\n", x, category[i].contact[x].name); + } + } + } else if (choice1 == 3){ // Prints categories and contacts + categories(2); + printf("\nSelect category: "); + scanf("%d", &i); + printf("Select contact: "); + scanf("%d", &x); + + for (x = 0; x < category[i].contactCount; x++){ + printf("Name: %s\n", category[i].contact[x].name); + printf("Phone Number: %d\n", category[i].contact[x].telnum); + printf("Rating: %s\n", category[i].contact[x].rating); + printf("Address: %s\n", category[i].contact[x].address); + } + }else if (choice1 == 4){ // Edits contact Details + int editChoice = 0; + + categories(2); + printf("Select category: "); + scanf("%d", &i); + printf("Select contact: "); + scanf("%d", &x); + + printf("Current Details\n"); + categories(5); + + printf("\nWhat would you like to edit? (1)Name (2)Number (3)Rating (4)Address\n"); + scanf("%d", &editChoice); + + if (editChoice == 1){ //name + printf("Enter new name: "); + scanf(" %[^\n]%*c", category[i].contact[x].name); + }else if (editChoice == 2){ // number + do{ // gets phone number and makes sure it is only made of integers; + printf("Enter phone number: "); + phone = scanf("%d%c", &category[i].contact[x].telnum, &enter); + if (phone != 2 || enter != '\n'){ + printf("Invalid number, try again.\n"); + while (getchar() != '\n') + ; + } + }while (phone != 2 || enter != '\n'); + }else if (editChoice == 3){ // rating + scanf("%s", category[i].contact[x].rating); + }else if (editChoice == 4){ // address + scanf("%[^\n]%*c", category[i].contact[x].address); + } + + printf("Updated details successfully.\n"); + } +} + +int main(){ + int select = 0; + int *ptrS = &select; + printf("Welcome!\n"); + while (select != 5){ + printf("\nWhat would you like to do? (1)Create a new contact (2)View categories (3)View specific contacts (4)Edit details (5)Exit\n"); + userSelect(ptrS); + } + return 0; +} diff --git a/final b/final new file mode 100755 index 0000000000000000000000000000000000000000..e30caa9bf80f7a198dc72ec096d2bc6e22b60ff0 GIT binary patch literal 13136 zcmeHNeQ+DcbzcC4MA0%x$&~eBO>~OPhIC4pq&`g9sRfXPbo5XXO_8!})ew_akS(C!c2`0Tpq1Pz%B%KlBlFIf` z+vw^ScKhufaKw9vurB^zq$EqJ_Z>Y*`5)iISx^tpNZMn-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es 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100755 final.out diff --git a/final.out b/final.out new file mode 100755 index 0000000000000000000000000000000000000000..e30caa9bf80f7a198dc72ec096d2bc6e22b60ff0 GIT binary patch literal 13136 zcmeHNeQ+DcbzcC4MA0%x$&~eBO>~OPhIC4pq&`g9sRfXPbo5XXO_8!})ew_akS(C!c2`0Tpq1Pz%B%KlBlFIf` z+vw^ScKhufaKw9vurB^zq$EqJ_Z>Y*`5)iISx^tpNZMn-Oj4=$IP}QR+f8*suus&t zP+YEy_DL$E^I$YGv}MzS(O`2l5=)IYkGF4W-m=M^jJw--yU9Mu?$|ZJYm#wPz>&}O zxM&Pe`I+s%2s=KSyt(qJugvC;y|>}aYM)^rzuO8zj!FF@hi!ZaAIdJF(&%+T0JBxlLxS&Al03*%5y`|51UnZpl7gK~6 zHJ0EGDGb_Dg3B>a#qA|{>3zXdf>YfxsT0?#)r|AwH40NFbGkGCyC_j7&Q+f^Bnq29 zKvALL2L5Z;d5|N1gbHUb7mym>C7zlxJHz?6iKiya<~aY)#5;&T#rZdhCzofx#rYo* zPp-~RaXtY)JO!So*7v&87Y?ZDx7CR&*L(ZBr*pYF4^yYl^l~zNsn)~tUx(t2aP7J- z#!hQ!=z!Y14@8}qbE)Zf4&HZ~Oi}Ze?axv{;WC7ea{K$wQmevl$-heF1M2Vn2RCr$ zmIDUV^mX-2ew%80UA=HiUtwCiOIoX4$M&B!>Ob;ZtKmOOEgOJhJ_g73zwTTF$o3(x zDXZXysZMNTDd*L%LC-YyJ}DGt_Rl^C9m=C;6g7P~uV#FCHT`<_5*o~<^XG3B3e&z{ z^G2aC!zSizsij%!gZv*O@>j#8L$Dn%bw&Ot!Mi2w0PG-ml;Cy=R{^Gu$?qk2y@Z|m zz1hpCJkL-sfogg>|0KMedgH8cv?YD`Ej68*396Z@hDMlB)4sXZT*mj7dQy$dR5t<1 z_-0hwj5?7EqVRgwxeOM+|8b#^U51>|uq@blI>(pVp?f{U)WD3IhK(GVI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s3b z^jDg(@_%a4m*?Q8gnk#K=hfW(!WfQj&BT^0IDTApV{g3wC4wRxFWv u5+U9)MR?I4D27BkJ)DqeIJDuCag+DOCBQ1xpZfv|koXZiBg_A-_5TmZg~D|J literal 0 HcmV?d00001 From 1831088e2077fbd0fe28cea452a9b41239101095 Mon Sep 17 00:00:00 2001 From: julialaurentan Date: Fri, 15 Jul 2016 07:30:00 -0400 Subject: [PATCH 5/8] Delete final --- final | Bin 13136 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100755 final diff --git a/final b/final deleted file mode 100755 index e30caa9bf80f7a198dc72ec096d2bc6e22b60ff0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13136 zcmeHNeQ+DcbzcC4MA0%x$&~eBO>~OPhIC4pq&`g9sRfXPbo5XXO_8!})ew_akS(C!c2`0Tpq1Pz%B%KlBlFIf` z+vw^ScKhufaKw9vurB^zq$EqJ_Z>Y*`5)iISx^tpNZMn-Oj4=$IP}QR+f8*suus&t zP+YEy_DL$E^I$YGv}MzS(O`2l5=)IYkGF4W-m=M^jJw--yU9Mu?$|ZJYm#wPz>&}O zxM&Pe`I+s%2s=KSyt(qJugvC;y|>}aYM)^rzuO8zj!FF@hi!ZaAIdJF(&%+T0JBxlLxS&Al03*%5y`|51UnZpl7gK~6 zHJ0EGDGb_Dg3B>a#qA|{>3zXdf>YfxsT0?#)r|AwH40NFbGkGCyC_j7&Q+f^Bnq29 zKvALL2L5Z;d5|N1gbHUb7mym>C7zlxJHz?6iKiya<~aY)#5;&T#rZdhCzofx#rYo* zPp-~RaXtY)JO!So*7v&87Y?ZDx7CR&*L(ZBr*pYF4^yYl^l~zNsn)~tUx(t2aP7J- z#!hQ!=z!Y14@8}qbE)Zf4&HZ~Oi}Ze?axv{;WC7ea{K$wQmevl$-heF1M2Vn2RCr$ zmIDUV^mX-2ew%80UA=HiUtwCiOIoX4$M&B!>Ob;ZtKmOOEgOJhJ_g73zwTTF$o3(x z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Qs zQA{a5-9PgmtuJt^!y3a#?RF2($aA)GpJkL9vNBI}1Fprmq`q8V%X6#>%1V>GA4{wi znNoeZ4yXGgrTYzH{#*6CP=e2naasRKyNAo36oB;K$W@1-;28D+oUkJXG5^U%X*vLg_I6T#PUz1G{W>8m{g-l* z(sPFPijtT6iE0rjkI-KPTI#=m8Lj_FRO-uphbr{3lHp0#Z*Bikl#*zNA!hDR28F)d zACo@Wvg)4zMt+fhl;l3DN0k4Zs6WjrN)(V{Q+MMs3b z^jDg(@_%a4m*?Q8gnk#K=hfW(!WfQj&BT^0IDTApV{g3wC4wRxFWv u5+U9)MR?I4D27BkJ)DqeIJDuCag+DOCBQ1xpZfv|koXZiBg_A-_5TmZg~D|J From 9aedf22a19fc449fd3ccbd30e2b3b81f2fac6615 Mon Sep 17 00:00:00 2001 From: julialaurentan Date: Fri, 15 Jul 2016 11:50:57 -0400 Subject: [PATCH 6/8] Julia Tan - FinalProject --- contacts.c | 10 ++++------ final.out | Bin 13136 -> 13136 bytes 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/contacts.c b/contacts.c index e8389d0..d374300 100644 --- a/contacts.c +++ b/contacts.c @@ -23,7 +23,6 @@ void newContact(int categoryNum, newCat* category); void userSelect(int* a){ // Process what the user wants to do scanf("%d", a); - int selected = 0; if (*a == 1){ // Create a new contact categories(1); }else if (*a == 2){ // View categories @@ -99,7 +98,7 @@ void categories(int choice1){ printf("Category successfully created.\n\n"); } printf("\nSelect a category to put your new contact in:"); - printf("(0) Create a new category\n"); + printf("\n(0) Create a new category\n"); categories(2); scanf("%d", &userIn); } @@ -133,9 +132,6 @@ void categories(int choice1){ printf("Select contact: "); scanf("%d", &x); - printf("Current Details\n"); - categories(5); - printf("\nWhat would you like to edit? (1)Name (2)Number (3)Rating (4)Address\n"); scanf("%d", &editChoice); @@ -153,9 +149,11 @@ void categories(int choice1){ } }while (phone != 2 || enter != '\n'); }else if (editChoice == 3){ // rating + printf("Enter new rating: "); scanf("%s", category[i].contact[x].rating); }else if (editChoice == 4){ // address - scanf("%[^\n]%*c", category[i].contact[x].address); + printf("Enter new address: "); + scanf(" %[^\n]%*c", category[i].contact[x].address); } printf("Updated details successfully.\n"); diff --git a/final.out b/final.out index e30caa9bf80f7a198dc72ec096d2bc6e22b60ff0..1e417d3bf3bec0ff4ba5c761dcdb77471eb5e283 100755 GIT binary patch delta 1610 zcmZuxeQZ-z6o2ovuOI98+AbZ;t=$J*$=H@T86`_BE@d4EERhMy6zkT(jOny%ohFX4 zlo{)bvwD`GnGhrZwaLC|!?(6zCh%b4$=l*`b zbI!fzo_muW$&PqZJ!GZCZ|L=(cvIS(nWW7g(MZEldeTC>xo5h*?A)+>{CMJI4K!5_ zm)=ag$=GD{B#f{ZHyM4g-Z>xVo%6*;`3a+k`jj}Q#%~J(K{+ZqM@O_gO~7G>qNY2t zFoQ4xRB9iAw-6Y9Rpix(K5``GgnXEgj;s$G&f|ZsQ}HGHlznchQ+k4WKmFS5(jCXJ7<10=*1SgkIhe}+fZ&$e#AiRcA_ZYGwv z;}-=%IGsG{rq-mz;+!{0R_#r4ElG~`e&nFsUl<10 zW8A57IHa+y-zoX@-@rzB)tkJteTEU`Lz1X9Bl`YM(Q|NHvr!Y3R99iEc8zvWntwP4 zI{hl}7|hy366nu@dMMJdnhzwx3RSv_zNfK9(cV*X!@!ehjd>^VK&VXN{vgNqnWR7c z&;Koa0?{Q4e=8%pYvBnZN@AqcBN=`oyD_+;Q`i7O&O1Ra&f~llZ)2v~4}wu)=F4c-woZQ=X-@Wp(a?BcL zQ`_J>Lq%bb@K)rf^Z4h9twtNASIKQ|gL{m2!%SKbzB=1cX(-x9P9U+x_&aT@cG(+3 z0e?7P_uGSk9(x;_yShRzKvix(c`PX4bGNy?!EhiX@*#h?Gq`K5ohs|57EynDdnnM| zz19v6vkRKdFS`q71z`x?-^Q^W$2a~Ggi|=y{w)X>acsxs&Et3(JD>nxvR1qd^*Ejb zlf_9_gWFO??}bi_)A0>PIE+eao!GmIP}2BXJDff0?P`zc6@_=4lgsO~DRso%Wgk{t%SOSbrhd6cFWO0Nc4Jv{{n+1H-&4hg7x1!m- z_m^VtYn)oT2%qR~z3dJQACm*o201YNwX`Vs$!9ECzItC#<{H+S&74s(_!kYECCYps zXb4#jrm+Sw0wNDF+?>W*#9D@5VYr%MSjo)ZoGhgaWlKxgOD5QcxdOv;atjpd8-$Dh zDvD&YrS~Dh5q*_wBTY zL}tP-MRixv8l0iSItdMFMeUG_!BO3LaGTtEZ_*xwMpM3P`fn^csfNumnd~tR1E#!^ zYpA2TqGWmgRHMR_h$;}>hljI(#}mZ8CT_zOQzchnPan@Vpxoo;M^(MF2BnrQ@CGMT z)_m+CzAyPxyRcRwKZB6LW0$pj8s*K!e6x1ioBIM_&ysn7}~maW`j90%M<1|K;9trn3xqxwIE z0gE{B-MtO{-$fZX+3>^0>HLTVO=G6~G_!PU&fZ~fZHBR$RLiA$&osS@?xQll?8eF5KJO(H(Nv zcZAwr?805z_jBGp;yrlC^t|`Mc4*Ejg>UTnFq-wMuYN^QPGkNRTwlQTi$4|RGOq2n z73CJLfSuU~z>I^Ji&Ha%>rPznfX`7(4?vrvoKC`+qu8^G6{awf)LMlTnmS9SX2PsD z5R!|CRUUvFjsnjJ?z=zpe^J^{CJSRx6Zn%MM=YRz@QIDIGj?1YF~C`|BqroLGjh`3 zGz?Q8EwK}4thVqm4ef;ETSn+S*u3L(3Z}e0v^l*Us_N~r@sb?9W=#W^%FB%Dp7W3>-)?j|QZ<~h(u!j3 Ef51H$B>(^b From bcf6f2430b4f18b137a55e2a42f670691a7184b6 Mon Sep 17 00:00:00 2001 From: julialaurentan Date: Fri, 15 Jul 2016 12:50:43 -0400 Subject: [PATCH 7/8] projectreadme final --- ProjectREADME.txt | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/ProjectREADME.txt b/ProjectREADME.txt index c12ab96..c8f0179 100644 --- a/ProjectREADME.txt +++ b/ProjectREADME.txt @@ -1,13 +1,29 @@ -Contact Book +My Contacts App -This is a contact book that is able to: -- create and store contacts -- add and edit details to each contact -- organize contacts into custom categories -- display contact information +July 15, 2016 +Julia Tan -To navigate the application, use the number keys to select an option that is displayed. -All functions and instructions will be displayed on the screen. Enjoy! +Overview +The My Contacts program is designed to be an efficient contacts directory that is simple and user-friendly, yet allows for quick access to contact details. Unlike a regular contact book, this program is able to categorize contacts into groups, and also add ratings, which is especially useful for businesses such as restaurants. -Julia Tan -July 15, 2016 +Functions +This contact book is able to: +- Create and save your contacts +- Add and edit details to each contact, which are name, telephone number, ratings and address +- Create categories to store your contacts under +- Display all your contacts under a category +- Display all categories +- Display contact information of a contact + +How to Use +To navigate through the application, use the number keys to select what you want to do. Options of what the application can do for you at the current time will be displayed on the screen, with correspoinding number choices. + +The program will function until you 'Exit', which is an option that is also displayed on the screen. + +Review +The program is able to do all the functions specified on the project proposal. Input/output, conditional statements, loops, functions, arrays/strings and advanced data types were used to create this program. + +The way I coded it was quite different from how I imagined the game would be written. I used fout functions: the main function, a function that reads the number inputs the user selects, a function that creates new contacts and a function that does different things with the categories. I used a lot of if statements especially in the function that deals with the categories, to do different functions with the categories. + +Reasons for Making this Program +I chose to do this project because I wanted to create a program that someone would be able to benefit from. I also wanted to create a program that would be quite useful, compared to other types of programs such as games. Enjoy! From 1cacd4052e41d06fe163481bfa974a74bb031267 Mon Sep 17 00:00:00 2001 From: julialaurentan Date: Fri, 15 Jul 2016 14:15:12 -0400 Subject: [PATCH 8/8] final proj --- contacts.c | 82 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/contacts.c b/contacts.c index d374300..902d5e0 100644 --- a/contacts.c +++ b/contacts.c @@ -4,7 +4,7 @@ #include #include -typedef struct contact{ // Make a new contact +typedef struct contact{ char name[100]; int telnum; char rating[4]; @@ -14,11 +14,11 @@ typedef struct contact{ // Make a new contact typedef struct category{ char cname[100]; int contactCount; - newCon contact[50]; + newCon contact[50]; // Contacts are created under categories }newCat; void userSelect(int* a); -void categories(int choice1); +void categories(int choice); void newContact(int categoryNum, newCat* category); void userSelect(int* a){ // Process what the user wants to do @@ -33,42 +33,45 @@ void userSelect(int* a){ // Process what the user wants to do categories(4); }else if (*a == 5){ // Exit - }else{ - printf("Invalid selection. Please try again:\n"); + }else{ // Invalid input + printf("\nInvalid selection. Please try again:\n"); userSelect(a); } } -void newContact(int categoryNum, newCat* category){ // Add a new contact +void newContact(int categoryNum, newCat* category){ // Adds a new contact int *conCountPtr = &(category[categoryNum].contactCount); // Counts number of contacts within chosen category char enter; // Checks for \n symbol int phone; // evaluates scanf + // Create a new contact printf("New Contact\n"); + printf("Enter full name: "); - scanf(" %[^\n]%*c", category[categoryNum].contact[*conCountPtr].name); + scanf(" %[^\n]%*c", category[categoryNum].contact[*conCountPtr].name); // reads everything, even space characters, until it hits \n do{ // gets phone number and makes sure it is only made of integers printf("Enter phone number: "); phone = scanf("%d%c", &category[categoryNum].contact[*conCountPtr].telnum, &enter); - if (phone != 2 || enter != '\n'){ + if (phone != 2 || enter != '\n'){ // checks if the only character in input is the \n symbol (this would be true for integer inputs printf("Invalid number, try again.\n"); - while (getchar() != '\n') + while (getchar() != '\n') // clears input buffer ; } - }while (phone != 2 || enter != '\n'); + }while (phone != 2 || enter != '\n'); // while the input is not purely an integer value... printf("Enter rating: "); scanf(" %s", category[categoryNum].contact[*conCountPtr].rating); - + + while (getchar() != '\n'); printf("Enter address: "); scanf(" %[^\n]%*c", category[categoryNum].contact[*conCountPtr].address); printf("Contact successfully added.\n\n"); - (*conCountPtr)++; + (*conCountPtr)++; // Increments the number of contacts within the chosen category } -void categories(int choice1){ +void categories(int choice){ // Does category-related work static int catCount = 0; // counts number of existing categories static newCat category[10]; // creates an array of categories newCat *catPtr = category; // pointer to array of categories for functions @@ -76,41 +79,41 @@ void categories(int choice1){ int i = 0; // index for category array int x = 0; // index for contacts array inside the contacts array int *conCount = &category[i].contactCount; // pointer to number of contacts in array - int cat = 0; - int cont = 0; int phone; char enter; + int editChoice; // User's input for choosing what detail of contact to edit - - if (choice1 == 1){ // Select a category to put your contact in + if (choice == 1){ // Select a category to put your contact in printf("\nSelect a category to put your new contact in:\n"); printf("(0) Create a new category\n"); categories(2); scanf("%d", &userIn); // Create new category or choose existing - - while (userIn < 1){ - - if (userIn == 0){ // Creating a new category - catCount++; // Increases count of categories - printf("\nEnter name of new category: "); - scanf(" %[^\n]%*c", category[catCount].cname); // Renames new category - category[catCount].contactCount = 0; - printf("Category successfully created.\n\n"); - } + while (userIn == 0){ // While user has chosen to create a new category + catCount++; // Increases count of categories + printf("\nEnter name of new category: "); + scanf(" %[^\n]%*c", category[catCount].cname); // Names new category + category[catCount].contactCount = 0; // Sets number of contacts to 0 + printf("Category successfully created.\n\n"); + printf("\nSelect a category to put your new contact in:"); printf("\n(0) Create a new category\n"); categories(2); scanf("%d", &userIn); } - newContact(userIn, catPtr); // arg1 is number of categories, arg2 is pointer to category array - } else if (choice1 == 2){ // Print categories with contacts underneath - for (i = 1; i <= catCount; i++){ + if (userIn <= catCount){ // checks if user input is one of the choices listed + newContact(userIn, catPtr); // arg1 is number of categories, arg2 is pointer to category array + }else{ + printf("\n\nInvalid selection. Please try again: \n\n"); + categories(1); + } + } else if (choice == 2){ // Print categories with contacts underneath + for (i = 1; i <= catCount; i++){ // For each category printf("\n(%d) %s\n", i, category[i].cname); - for (x = 0; x < category[i].contactCount; x++){ - printf("- %d. %s\n", x, category[i].contact[x].name); + for (x = 0; x < category[i].contactCount; x++){ // For each contact under a single category + printf("- (%d) %s\n", x, category[i].contact[x].name); } } - } else if (choice1 == 3){ // Prints categories and contacts + } else if (choice == 3){ // Prints categories and contacts categories(2); printf("\nSelect category: "); scanf("%d", &i); @@ -123,9 +126,8 @@ void categories(int choice1){ printf("Rating: %s\n", category[i].contact[x].rating); printf("Address: %s\n", category[i].contact[x].address); } - }else if (choice1 == 4){ // Edits contact Details - int editChoice = 0; - + }else if (choice == 4){ // Edits contact Details + int editChoice = 0; // accepts input from user to edit contact details through a menu; categories(2); printf("Select category: "); scanf("%d", &i); @@ -138,9 +140,9 @@ void categories(int choice1){ if (editChoice == 1){ //name printf("Enter new name: "); scanf(" %[^\n]%*c", category[i].contact[x].name); - }else if (editChoice == 2){ // number + }else if (editChoice == 2){ // tel number do{ // gets phone number and makes sure it is only made of integers; - printf("Enter phone number: "); + printf("Enter phone number: "); // makes sure input is not invalid phone = scanf("%d%c", &category[i].contact[x].telnum, &enter); if (phone != 2 || enter != '\n'){ printf("Invalid number, try again.\n"); @@ -161,8 +163,8 @@ void categories(int choice1){ } int main(){ - int select = 0; - int *ptrS = &select; + int select = 0; // user's input to questions + int *ptrS = &select; // pointer to user's input (for other functions) printf("Welcome!\n"); while (select != 5){ printf("\nWhat would you like to do? (1)Create a new contact (2)View categories (3)View specific contacts (4)Edit details (5)Exit\n");