Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 32 //For loop used to create 7 random files, i is only incremented if a new file is created.
- 33 for (i = 0; i < 7; i++)
- 34 {
- 35 printf("\nstarting loop, i is: %d\n", i);
- 36 //Mods by 11 to get a number between 1 and 10.
- 37 switch (rand() % 11)
- 38 {
- 39 case 1:;
- 40 //Every if statement checks to see if a file exists, if it does, decrement i and continue with the loop
- 41 if (access("Bed_Room", F_OK) != -1)
- 42 { printf("Room exists. Decrementing i and not creating file...\n i is: %d\n", i);
- 43 --i;
- 44 break;
- 45 }
- 46 else
- 47 {
- 48 printf("Creating bedroom\n");
- 49 FILE *fp = fopen("Bed_Room", "aw+");
- 50 break;
- 51 }
- 52
- 53 case 2:;
- 54 if (access("Dungeon_Room", F_OK) != -1)
- 55 { printf("Room exists. Decrementing i and not creating file...\n i is: %d\n", i);
- 56 --i;
- 57 break;
- 58 }
- 59 else
- 60 {
- 61 printf("Creating dungeon room\n");
- 62 FILE *fp = fopen("Dungeon_Room", "aw+");
- 63 break;
- 64 }
- 65
- 66 case 3:;
- 67 if (access("Living_Room", F_OK) != -1)
- 68 { printf("Room exists. Decrementing i and not creating file...\n i is: %d\n", i);
- 69 --i;
- 70 break;
- 71 }
- 72 else
- 73 {
- 74 printf("creating living room\n");
- 75 FILE *fp = fopen("Living_Room", "aw+");
- 76 break;
- 77 }
- 78
- 79 case 4:;
- 80 if (access("Music_Room", F_OK) != -1)
- 81 { printf("Room exists. Decrementing i and not creating file...\n i is: %d\n", i);
- 82 --i;
- 83 break;
- 84 }
- 85 else
- 86 {
- 87 printf("creating music room\n");
- 88 FILE *fp = fopen("Music_Room", "aw+");
- 89 break;
- 90 }
- 91
- 92 case 5:;
- 93 if (access("Study_Room", F_OK) != -1)
- 94 { printf("Room exists. Decrementing i and not creating file...\n i is: %d\n", i);
- 95 --i;
- 96 break;
- 97 }
- 98 else
- 99 {
- 100 printf("creating study room\n");
- 101 FILE *fp = fopen("Study_Room", "aw+");
- 102 break;
- 103 }
- 104
- 105 case 6:;
- 106 if (access("Rec_Room", F_OK) != -1)
- 107 { printf("Room exists. Decrementing i and not creating file...\n i is: %d\n", i);
- 108 --i;
- 109 break;
- 110 }
- 111 else
- 112 {
- 113 printf("creating rec room\n");
- 114 FILE *fp = fopen("Rec_Room", "aw+");
- 115 break;
- 116 }
- 117
- 118 case 7:;
- 119 if (access("Kitchen_Room", F_OK) != -1)
- 120 { printf("Room exists. Decrementing i and not creating file...\n i is: %d\n", i);
- 121 --i;
- 122 break;
- 123 }
- 124 else
- 125 {
- 126 printf("creating kitchen room\n");
- 127 FILE *fp = fopen("Kitchen_Room", "aw+");
- 128 break;
- 129 }
- 130
- 131 case 8:;
- 132 if (access("Workout_Room", F_OK) != -1)
- 133 { printf("Room exists. Decrementing i and not creating file...\n i is: %d\n", i);
- 134 --i;
- 135 break;
- 136 }
- 137 else
- 138 {
- 139 printf("creating workout room\n");
- 140 FILE *fp = fopen("Workout_Room", "aw+");
- 141 break;
- 142 }
- 143
- 144 case 9:;
- 145 if (access("Theater_Room", F_OK) != -1)
- 146 { printf("Room exists. Decrementing i and not creating file...\n i is: %d\n", i);
- 147 --i;
- 148 break;
- 149 }
- 150 else
- 151 {
- 152 printf("creating theaterroom\n");
- 153 FILE *fp = fopen("Theater_Room", "aw+");
- 154 break;
- 155 }
- 156
- 157 case 10:;
- 158 if (access("Void_Room", F_OK) != -1)
- 159 {
- 160 printf("Room exists. Decrementing i and not creating file...\n i is: %d\n", i);
- 161 --i;
- 162 break;
- 163 }
- 164 else
- 165 {
- 166 printf("creating void room\n");
- 167 FILE *fp = fopen("Void_Room", "aw+");
- 168 break;
- 169 }
- 170 default:
- 171 printf("Something is wrong\n");
- 172 printf("i is %d\n randNum is: %d\n", i, rand() % 11);
- 173 return 1;
- 174 }
- 175 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement