├── README.md ├── ebraj.txt ├── infobook.c ├── infobook.exe └── snaps ├── front.JPG └── main.JPG /README.md: -------------------------------------------------------------------------------- 1 | ## And yeah, it requires the password, Password : ebrajdon 2 | Phonebook is a simple project built in C where you can save the Infos of a person and can modify and delete it too. 3 | 4 | ## Some Snaps 5 | ### 01. Password Page 6 | ![Front](/snaps/front.JPG) 7 | 8 | ### 02. Main Page 9 | ![Main](/snaps/main.JPG) 10 | -------------------------------------------------------------------------------- /ebraj.txt: -------------------------------------------------------------------------------- 1 | Ebraj Chauthe Male gurungebraj22@gmail.com 9805813974 2 | Anizh Syangja Male problemslution222@gmail.com 9846093920 3 | Ebraj Chauthe Male gurungebraj22@gmail.com 13974 4 | -------------------------------------------------------------------------------- /infobook.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | void menu(void); 7 | void password(void); 8 | void namefun(void); 9 | void searchfun(void); 10 | void listfun(void); 11 | void modifyfun(void); 12 | void deletefun(void); 13 | void exitfun(void); 14 | void gotoxy(int x,int y){ 15 | COORD c; 16 | c.X=x; 17 | c.Y=y; 18 | SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c); 19 | } 20 | 21 | int main(){ 22 | system("color B"); 23 | password(); 24 | getch(); 25 | } 26 | 27 | void namefun(){ 28 | system("cls"); 29 | gotoxy(31,4); 30 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB NEW SECTION \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xB3"); 31 | FILE *fptr; 32 | char name[100]; 33 | char address[100]; 34 | char gmail[100]; 35 | double phone; 36 | char gender[8]; 37 | fptr=fopen("ebraj.txt","ab+");//ab+ gives us the ability of writing the function and add the second data in the existing one... 38 | if(fptr==NULL){ 39 | printf("Failed to create the required file."); 40 | } 41 | else{ 42 | gotoxy(31,6); 43 | printf("Name:\t"); 44 | gotoxy(52,6); 45 | gets(name); 46 | gotoxy(31,7); 47 | printf("Address:\t"); 48 | gotoxy(52,7); 49 | gets(address); 50 | gotoxy(31,8); 51 | printf("Gender:\t"); 52 | gotoxy(52,8); 53 | gets(gender); 54 | gotoxy(31,9); 55 | printf("Gmail:\t"); 56 | gotoxy(52,9); 57 | gets(gmail); 58 | gotoxy(31,10); 59 | printf("Phone Number:\t"); 60 | gotoxy(52,10); 61 | scanf("%lf",&phone); 62 | fprintf(fptr,"%s %s %s %s %.0lf\n",name,address,gender,gmail,phone); 63 | } 64 | fclose(fptr); 65 | system("cls"); 66 | char ch; 67 | gotoxy(31,4); 68 | printf("Do you wanna add more datas.Press y for that:"); 69 | Sleep(1000); 70 | fflush(stdin); 71 | while((ch=getch())=='y'){ 72 | menu(); 73 | } 74 | } 75 | 76 | void searchfun(){ 77 | FILE *fptr; 78 | int flag=0; 79 | int res; 80 | char name[100]; 81 | char address[100]; 82 | char gmail[100]; 83 | double phone; 84 | char gender[8]; 85 | char name1[100]; 86 | system("cls"); 87 | fflush(stdin); 88 | gotoxy(18,2); 89 | printf("\xDB\xDB\xDB Enter the name of the person you want to see the detail:: "); 90 | gets(name1); 91 | fptr=fopen("ebraj.txt","r"); 92 | //fflush(stdin); 93 | while(fscanf(fptr,"%s %s %s %s %lf\n",name,address,gender,gmail,&phone)!=EOF){ 94 | res=strcmp(name,name1); 95 | if(res==0){ 96 | gotoxy(39,4); 97 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB Record Found \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xB3"); 98 | gotoxy(28,5); 99 | printf("----------------------------------------"); 100 | gotoxy(31,6.5); 101 | printf("\xB3\xB2\xB2\xB2 Name:\t%s",name); 102 | gotoxy(31,7); 103 | printf("\xB3\xB2\xB2\xB2 Address:\t%s",address); 104 | gotoxy(31,8); 105 | printf("\xB3\xB2\xB2\xB2 Gender:\t%s",gender); 106 | gotoxy(31,9); 107 | printf("\xB3\xB2\xB2\xB2 Gmail:\t%s",gmail); 108 | gotoxy(31,10); 109 | printf("\xB3\xB2\xB2\xB2 Phone Number:\t%.0lf",phone); 110 | gotoxy(31,11); 111 | printf("----------------------------------------"); 112 | flag=1; 113 | Sleep(1000); 114 | gotoxy(18,12); 115 | printf("Enter y for menu option."); 116 | while(getch()=='y'){ 117 | menu(); 118 | } 119 | } 120 | } 121 | if(flag==0){ 122 | system("cls"); 123 | gotoxy(39,4); 124 | printf("No record found.");; 125 | gotoxy(39,6); 126 | printf("Enter a to enter file again or double y key to open menu section:"); 127 | if(getch()=='a'){ 128 | system("cls"); 129 | searchfun(); 130 | } 131 | 132 | } 133 | 134 | 135 | fclose(fptr); 136 | } 137 | void listfun(){ 138 | FILE *fptr; 139 | char name[100],address[100],gmail[100],gender[8]; 140 | double phone; 141 | int f; 142 | fptr=fopen("ebraj.txt","r"); 143 | system("cls"); 144 | gotoxy(31,2); 145 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB LIST SECTION OPENED \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xB3"); 146 | printf("\n"); 147 | while(fscanf(fptr,"%s %s %s %s %lf",name,address,gender,gmail,&phone)!=EOF){ 148 | 149 | printf("------------------------------------------\n"); 150 | printf("Name:%s\n",name); 151 | printf("Address:%s\n",address); 152 | printf("Gender:%s\n",gender); 153 | printf("Gmail:%s\n",gmail); 154 | printf("Phone:%.0lf\n",phone); 155 | f=1; 156 | printf("------------------------------------------"); 157 | printf("\n\n"); 158 | } 159 | Sleep(1000); 160 | printf("Enter y for menu section:"); 161 | while(getch()=='y'){ 162 | menu(); 163 | } 164 | fclose(fptr); 165 | } 166 | 167 | 168 | 169 | void modifyfun(){ 170 | FILE *fptr,*fptr1; 171 | char name[100],address[100],gmail[100],gmail1[100],address1[100],name1[100],gender[8],gender1[8]; 172 | int res,f=0; 173 | double phone,phone1; 174 | fptr=fopen("ebraj.txt","r"); 175 | fptr1=fopen("temp.txt","a"); 176 | system("cls"); 177 | gotoxy(31,4); 178 | printf("Enter the name: "); 179 | gets(name1); 180 | system("cls"); 181 | while(fscanf(fptr,"%s %s %s %s %lf\n",name,address,gender,gmail,&phone)!=EOF){ 182 | res=strcmp(name,name1); 183 | if(res==0) 184 | { 185 | f=1; 186 | gotoxy(31,4); 187 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB MODIFY SECTION OPENED \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xB3"); 188 | gotoxy(31,6); 189 | printf("Enter the new address:"); 190 | scanf("%s",address1); 191 | gotoxy(31,7); 192 | printf("Enter the gender:"); 193 | scanf("%s",gender1); 194 | gotoxy(31,8); 195 | printf("Enter the new gmail:"); 196 | scanf("%s",gmail1); 197 | gotoxy(31,9); 198 | printf("Enter the new phone number:"); 199 | scanf("%lf",&phone1); 200 | fprintf(fptr1,"%s %s %s %s %.0lf\n",name,address1,gender1,gmail1,phone1); 201 | 202 | }else{ 203 | fprintf(fptr1,"%s %s %s %s %.0lf\n",name,address,gender,gmail,phone); 204 | } 205 | } 206 | if(f==0){ 207 | printf("Record Not found."); 208 | } 209 | fclose(fptr); 210 | fclose(fptr1); 211 | fptr=fopen("ebraj.txt","w"); 212 | fclose(fptr); 213 | fptr=fopen("ebraj.txt","a"); 214 | fptr1=fopen("temp.txt","r"); 215 | while(fscanf(fptr1,"%s %s %s %s %lf\n",name,address,gender,gmail,&phone)!=EOF){ 216 | fprintf(fptr,"%s %s %s %s %.0lf\n",name,address,gender,gmail,phone); 217 | 218 | } 219 | 220 | fclose(fptr); 221 | fclose(fptr1); 222 | fptr1=fopen("temp.txt","w"); 223 | fclose(fptr1); 224 | printf("\n\nPress y for menu option."); 225 | fflush(stdin); 226 | if(getch()=='y'){ 227 | menu(); 228 | } 229 | } 230 | void deletefun(){ 231 | FILE *fptr,*fptr1; 232 | char name[100],address[100],gmail[100],gmail1[100],address1[100],name1[100],gender[8]; 233 | int res,f=0; 234 | double phone,phone1; 235 | fptr=fopen("ebraj.txt","r"); 236 | fptr1=fopen("temp.txt","a"); 237 | system("cls"); 238 | gotoxy(31,4); 239 | printf("Enter the CONTACT name that you want to delete: "); 240 | gets(name1); 241 | system("cls"); 242 | while(fscanf(fptr,"%s %s %s %s %lf\n",name,address,gender,gmail,&phone)!=EOF){ 243 | res=strcmp(name,name1); 244 | if(res==0) 245 | { 246 | f=1; 247 | printf("Record deleted successfully"); 248 | 249 | }else{ 250 | fprintf(fptr1,"%s %s %s %s %.0lf\n",name,address,gender,gmail,phone); 251 | } 252 | } 253 | if(f==0){ 254 | printf("Record Not found."); 255 | } 256 | fclose(fptr); 257 | fclose(fptr1); 258 | fptr=fopen("ebraj.txt","w"); 259 | fclose(fptr); 260 | fptr=fopen("ebraj.txt","a"); 261 | fptr1=fopen("temp.txt","r"); 262 | while(fscanf(fptr1,"%s %s %s %s %lf\n",name,address,gender,gmail,&phone)!=EOF){ 263 | fprintf(fptr,"%s %s %s %s %.0lf\n",name,address,gender,gmail,phone); 264 | 265 | } 266 | 267 | fclose(fptr); 268 | fclose(fptr1); 269 | fptr1=fopen("temp.txt","w"); 270 | fclose(fptr1); 271 | printf("\n\nPress y for menu option."); 272 | fflush(stdin); 273 | if(getch()=='y'){ 274 | menu(); 275 | }; 276 | } 277 | void exitfun(){ 278 | system("cls"); 279 | gotoxy(31,4); 280 | printf("\xDB\xDB\xDB\xDB TEAM MEMBERS \xDB\xDB\xDB\xDB"); 281 | gotoxy(31,6); 282 | printf("\xDB EBRAJ GURUNG."); 283 | gotoxy(31,8); 284 | printf("\xDB BEEKASH BASAULA."); 285 | gotoxy(31,10); 286 | printf("\xDB SAMUNDRA POUDEL."); 287 | gotoxy(31,12); 288 | printf("\xDB SAGAR DHAKAL."); 289 | } 290 | void password(void){ 291 | char passwords[20]={"ebrajdon"}; 292 | gotoxy(22,2); 293 | int j; 294 | int z; 295 | char name[40]="Authorized Person Only"; 296 | z=strlen(name); 297 | for(j=0;j<=16;j++){ 298 | Sleep(50); 299 | printf("\xDB"); 300 | } 301 | for(j=0;j<=z;j++){ 302 | Sleep(60); 303 | printf(" %c",name[j]); 304 | } 305 | for(j=0;j<=16;j++){ 306 | Sleep(50); 307 | printf("\xDB"); 308 | } 309 | gotoxy(30,4); 310 | printf("Password:"); 311 | char ch,pass[20]; 312 | char w='*'; 313 | int i=0; 314 | while(ch!=13 && i < 20){ 315 | ch=getch(); 316 | if(ch!=13 && ch!=8){ 317 | printf("%c",w); 318 | pass[i]=ch; 319 | i++; 320 | } 321 | else if(ch==8 && i>0) { 322 | printf("\b \b"); 323 | i--; 324 | } 325 | } 326 | pass[i]='\0'; 327 | if(strcmp(pass,passwords)==0){ 328 | gotoxy(30,6); 329 | printf("CORRECT PASSWORD."); 330 | Sleep(1000); 331 | menu(); 332 | } 333 | else{ 334 | gotoxy(30,6); 335 | printf("You entered the wrong password."); 336 | Sleep(700); 337 | system("cls"); 338 | password(); 339 | } 340 | 341 | } 342 | 343 | 344 | void menu(){ 345 | system("cls"); 346 | gotoxy(30,1); 347 | printf("\xB3\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2 PHONEBOOK DIRECTORY \xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB3"); 348 | gotoxy(31,4); 349 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 1.Add New"); 350 | gotoxy(31,7); 351 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 2.Search"); 352 | gotoxy(31,10); 353 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 3.List"); 354 | gotoxy(31,13); 355 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 4.Modify"); 356 | gotoxy(31,16); 357 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 5.Delete"); 358 | gotoxy(31,19); 359 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 6.Exit"); 360 | switch(getch()){ 361 | case '1': 362 | namefun(); 363 | break; 364 | case '2': 365 | searchfun(); 366 | break; 367 | case '3': 368 | listfun(); 369 | break; 370 | case '4': 371 | modifyfun(); 372 | break; 373 | case '5': 374 | deletefun(); 375 | break; 376 | case '6': 377 | exitfun(); 378 | break; 379 | default: 380 | system("cls"); 381 | printf("Invalid Enter."); 382 | getch(); 383 | } 384 | } 385 | 386 | 387 | -------------------------------------------------------------------------------- /infobook.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebraj/Phonebook-C-Project/aae87b56f5bd23beb1dd65a22a09171427564aa0/infobook.exe -------------------------------------------------------------------------------- /snaps/front.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebraj/Phonebook-C-Project/aae87b56f5bd23beb1dd65a22a09171427564aa0/snaps/front.JPG -------------------------------------------------------------------------------- /snaps/main.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebraj/Phonebook-C-Project/aae87b56f5bd23beb1dd65a22a09171427564aa0/snaps/main.JPG --------------------------------------------------------------------------------