forked from malmhaug/C_AbsBegin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC6E3FriendList.c
51 lines (42 loc) · 1.13 KB
/
C6E3FriendList.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* Challanges Ch6E3 - friendList */
// By Jim-Kristian Malmhaug | Date: 17 September 2013
//Notes: Friend List, write up to five names with maximum 10 characters. Had to use string to get this done!
//References:
#include <stdio.h>
main() {
char cList[10][5] = {{}};
char string[10] = {};
int iNum = 0;
int iSelect = 0;
int i = 0;
int j = 0;
int k = 0;
do{
printf("\n\n*** Friend List ***\n\nWhat will you do?\n\n1. Write a friends name in the list.\n2. Print out the names in the list.\n3. Quit\n---> ");
scanf(" %d", &iSelect);
switch(iSelect) {
case 1:
if (iNum < 5){
printf("\nEnter name: ");
scanf("%s", string);
for(i = 0 ; i < 10 ; i++) {
cList[i][iNum] = string[i];
}
iNum++;
}
else{
printf("Friends list is full!");
}
break;
case 2:
printf("\nNames stored in list:\n\n");
for(j = 0 ; j < iNum ; j++) {
for(k = 0 ; k < 10 ; k++) {
printf("%c", cList[k][j]);
}
printf("\n");
}
break;
}
}while(iSelect != 3);
}