├── .gitignore ├── ATM-machine ├── CProgram.c └── readme.md ├── Bank Management System ├── Bank.C ├── Readme.md └── images │ ├── 1.png │ ├── 10.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ └── 9.png ├── C Clock ├── Readme.md ├── clockAutomate.c └── learn.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Calculator ├── Scientific Calculator.c └── readme.md ├── Calendar With C ├── Readme.md └── calendar.c ├── Employee-Management-System ├── Employee Management System-github.c └── README.md ├── Grep_Project ├── Makefile ├── README.md ├── Screenshots │ ├── A.png │ ├── H.png │ ├── L.png │ ├── Li.png │ ├── b.png │ ├── c.png │ ├── cv.png │ ├── h.png │ ├── help.png │ ├── i.png │ ├── in.png │ ├── l.png │ ├── li.png │ ├── m.png │ ├── n.png │ ├── normal.png │ ├── r.png │ ├── ri.png │ ├── rv.png │ ├── standard_i.png │ ├── standard_input.png │ ├── standard_v.png │ ├── standard_vi.png │ ├── v.png │ ├── vn.png │ └── w.png ├── dir.c ├── grep.c ├── header.h ├── mystrstr.c ├── mystrstrcase.c ├── mystrtok_multi.c ├── standard_input.c ├── standard_options.c ├── test_dir │ ├── header.h │ ├── test │ │ ├── header.h │ │ ├── test2 │ │ │ ├── header.h │ │ │ └── testfile.test │ │ └── testfile.test │ └── testfile.test ├── testfile.test └── usage.c ├── Guess the number ├── guess_game.c └── readme.md ├── LICENSE ├── Library Management ├── library-management-project-in-c-programming.png ├── main.c └── readme.md ├── Matrix-Calculator ├── .DS_Store ├── README.md └── main.c ├── Mini-Voting-System ├── Election.h ├── Main.c └── readme.md ├── Musicplayer ├── README.md └── music_player.c ├── Phonebook-C-Project ├── README.md ├── abc.txt ├── phonebook.c ├── phonebook.exe ├── sample.txt └── screenshots │ ├── front.jpg │ └── main.jpg ├── Playback Speed Calculator ├── Readme.md └── sourceCode.c ├── README.md ├── Snake, Water, Gun game ├── readme.md └── snake_game.c ├── Space, newline ommiter ├── compress.txt ├── file_compressor.c ├── file_compressor.exe ├── index.html └── readme.md ├── Tic-Tac-Toe ├── README.md ├── score.txt └── tic-tac-toe.c ├── multiplication table generator ├── multiplication_table.c ├── multiplication_table.exe ├── readme.md └── table.txt ├── my-name └── arijit.c └── password_generator ├── main.c └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.exe 3 | -------------------------------------------------------------------------------- /ATM-machine/CProgram.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | //Functions 8 | void login(); 9 | void mainMenu(); 10 | void checkBalance(float balance); 11 | float moneyDeposit(float balance); 12 | float moneyWithdraw(float balance); 13 | void menuExit(); 14 | void errorMessage(); 15 | 16 | 17 | //Main Code 18 | int main() { 19 | //Local Declarations 20 | int option; 21 | float balance = 15000.00; 22 | int choose; 23 | 24 | bool again = true; 25 | 26 | // insert code here... 27 | 28 | while (again) { 29 | mainMenu(); 30 | 31 | printf("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"); 32 | printf("Your Selection:\t"); 33 | scanf("%d", &option); 34 | 35 | 36 | switch (option) { 37 | case 1: 38 | system("CLS"); 39 | checkBalance(balance); 40 | break; 41 | case 2: 42 | system("CLS"); 43 | balance = moneyDeposit(balance); 44 | break; 45 | case 3: 46 | system("CLS"); 47 | balance = moneyWithdraw(balance); 48 | break; 49 | 50 | case 4: 51 | system("CLS"); 52 | menuExit(); 53 | return 0; 54 | 55 | default: 56 | errorMessage(); 57 | break; 58 | } 59 | 60 | printf("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n"); 61 | printf("Would you like to do another transaction:\n"); 62 | printf("< 1 > Yes\n"); 63 | printf("< 2 > No\n"); 64 | scanf("%d", &choose); 65 | 66 | system("CLS"); 67 | 68 | 69 | 70 | if (choose == 2) { 71 | again = false; 72 | menuExit(); 73 | 74 | } 75 | 76 | } 77 | 78 | 79 | return 0; 80 | }//main code 81 | 82 | 83 | 84 | //Functions 85 | 86 | void mainMenu() { 87 | 88 | printf("******************Hello!*******************\n"); 89 | printf("**********Welcome to ATM Banking***********\n\n"); 90 | printf("****Please choose one of the options below****\n\n"); 91 | printf("< 1 > Check Balance\n"); 92 | printf("< 2 > Deposit\n"); 93 | printf("< 3 > Withdraw\n"); 94 | printf("< 4 > Exit\n\n"); 95 | 96 | }//Main Menu 97 | 98 | void checkBalance(float balance) { 99 | printf("You Choose to See your Balance\n"); 100 | printf("\n\n****Your Available Balance is: $%.2f\n\n", balance); 101 | 102 | }//Check Balance 103 | 104 | float moneyDeposit(float balance) { 105 | float deposit; 106 | printf("You choose to Deposit a money\n"); 107 | printf("$$$$Your Balance is: $%.2f\n\n", balance); 108 | printf("****Enter your amount to Deposit\n"); 109 | scanf("%f", &deposit); 110 | 111 | 112 | balance += deposit; 113 | 114 | printf("\n****Your New Balance is: $%.2f\n\n", balance); 115 | return balance; 116 | 117 | }//money deposit 118 | 119 | float moneyWithdraw(float balance) { 120 | float withdraw; 121 | bool back = true; 122 | 123 | printf("You choose to Withdraw a money\n"); 124 | printf("$$$$Your Balance is: $%.2f\n\n", balance); 125 | 126 | while (back) { 127 | printf("Enter your amount to withdraw:\n"); 128 | scanf("%f", &withdraw); 129 | 130 | 131 | if (withdraw < balance) { 132 | back = false; 133 | balance -= withdraw; 134 | printf("\n$$$$Your withdrawing money is: $%.2f\n", withdraw); 135 | printf("****Your New Balance is: $%.2f\n\n", balance); 136 | 137 | } 138 | 139 | else { 140 | 141 | printf("+++You don't have enough money+++\n"); 142 | printf("Please contact to your Bank Customer Services\n"); 143 | printf("****Your Balance is: $%.2f\n\n", balance); 144 | 145 | } 146 | } 147 | return balance; 148 | 149 | 150 | }//money withdraw 151 | 152 | void menuExit() { 153 | printf("--------------Take your receipt!!!------------------\n"); 154 | printf("-----Thank you for using ATM Banking Machine!!!-----\n"); 155 | printf("-----BROUGHT TO YOU BY itsourcecode.com-----\n"); 156 | 157 | 158 | }//exit menu 159 | 160 | void errorMessage() {; 161 | printf("+++!!!You selected invalid number!!!+++\n"); 162 | }//error message 163 | 164 | 165 | /* Sample Output 166 | 167 | 168 | ******************Hello!******************* 169 | **********Welcome to ATM Banking*********** 170 | 171 | ****Please choose one of the options below**** 172 | < 1 > Check Balance 173 | < 2 > Deposit 174 | < 3 > Withdraw 175 | < 4 > Exit 176 | 177 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 178 | Your Selection: 1 179 | You Choose to See your Balance 180 | ****Your Available Balance is: $15000.00 181 | 182 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 183 | Would you like to do another transaction: 184 | < 1 > Yes 185 | < 2 > No 186 | 1 187 | ******************Hello!******************* 188 | **********Welcome to ATM Banking*********** 189 | 190 | ****Please choose one of the options below**** 191 | < 1 > Check Balance 192 | < 2 > Deposit 193 | < 3 > Withdraw 194 | < 4 > Exit 195 | 196 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 197 | Your Selection: 2 198 | You choose to Deposit a money 199 | $$$$Your Balance is: $15000.00 200 | 201 | ****Enter your amount to Deposit 202 | 1444 203 | ****Your New Balance is: $16444.00 204 | 205 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 206 | Would you like to do another transaction: 207 | < 1 > Yes 208 | < 2 > No 209 | 1 210 | ******************Hello!******************* 211 | **********Welcome to ATM Banking*********** 212 | 213 | ****Please choose one of the options below**** 214 | < 1 > Check Balance 215 | < 2 > Deposit 216 | < 3 > Withdraw 217 | < 4 > Exit 218 | 219 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 220 | Your Selection: 3 221 | You choose to Withdraw a money 222 | $$$$Your Balance is: $16444.00 223 | 224 | Enter your amount to withdraw: 225 | 600000 226 | +++You don't have enough money+++ 227 | Please contact to your Bank Customer Services 228 | ****Your Balance is: $16444.00 229 | 230 | Enter your amount to withdraw: 231 | 14000 232 | $$$$Your withdrawing money is: $14000.00 233 | ****Your New Balance is: $2444.00 234 | 235 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 236 | Would you like to do another transaction: 237 | < 1 > Yes 238 | < 2 > No 239 | 1 240 | ******************Hello!******************* 241 | **********Welcome to ATM Banking*********** 242 | 243 | ****Please choose one of the options below**** 244 | < 1 > Check Balance 245 | < 2 > Deposit 246 | < 3 > Withdraw 247 | < 4 > Exit 248 | 249 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 250 | Your Selection: 4 251 | --------------Take your receipt!!!------------------ 252 | -----Thank you for using ATM Banking Machine!!!----- 253 | -----BROUGHT TO YOU BY itsourcecode.com!!!----- 254 | Program ended with exit code: 0 255 | 256 | */ 257 | -------------------------------------------------------------------------------- /ATM-machine/readme.md: -------------------------------------------------------------------------------- 1 | ## ATM Machine 2 | 3 | This c-program is made to replicate the working of ATM machine. 4 | 5 | ### Functionalities 6 | 1. Check Balance 7 | 2. Withdraw 8 | 3. Deposit 9 | 4. Exit 10 | 11 | ### Find the working video below: 12 | 13 | 14 | https://user-images.githubusercontent.com/83108477/194906517-3dd91ccc-db09-420c-aef1-6eb54f51a859.mov 15 | 16 | -------------------------------------------------------------------------------- /Bank Management System/Bank.C: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | struct customer{ 7 | int acno; 8 | char name[20]; 9 | char type; 10 | float bal; 11 | }c1; 12 | void clrscr(); 13 | void open_account(); 14 | void deposit(); 15 | void withdraw(); 16 | void show_balance(); 17 | void show_all(); 18 | void modify_account(); 19 | void close_account(); 20 | 21 | int main(){ 22 | int ch; 23 | char s1[20],s2[20]="bank"; 24 | int i=0,ans; 25 | char ch1; 26 | // Password is "bank" 27 | printf("Enter your password :"); 28 | while((ch1=getch())!='\r'){ 29 | putch('*'); 30 | s1[i]=ch1; 31 | i++; 32 | } 33 | s1[i]='\0'; 34 | 35 | ans=strcmp(s1,s2); 36 | if(ans==0) 37 | printf("Welcome to Bank"); 38 | else{ 39 | printf("You are not authorized user"); 40 | getch();exit(0); 41 | } 42 | 43 | printf("****"); 44 | printf("\n\n\n\n\n\n"); 45 | printf(" ---WELCOME TO THE BANKING MANAGEMENT SYSTEM--- "); 46 | printf("\t\t\n\n\n\n"); 47 | printf(" *********************************************************************"); 48 | printf("\n\n\n\n\n\n"); 49 | 50 | printf(" PRESS ENTER KEY"); 51 | getch(); 52 | clrscr(); 53 | 54 | do{ 55 | clrscr(); 56 | printf("\n Enter"); 57 | printf("\n 1. Open New Account"); 58 | printf("\n 2. Deposit"); 59 | printf("\n 3. Withdraw"); 60 | printf("\n 4. Show Balance"); 61 | printf("\n 5. Show All"); 62 | printf("\n 6. Modify Account"); 63 | printf("\n 7. Close Account."); 64 | printf("\n 8. Exit\n"); 65 | printf("Enter your choice :"); 66 | scanf("%d",&ch); 67 | clrscr(); 68 | switch(ch){ 69 | case 1: 70 | open_account();break; 71 | case 2: 72 | deposit();break; 73 | case 3: 74 | withdraw();break; 75 | case 4: 76 | show_balance();break; 77 | case 5: 78 | show_all();break; 79 | case 6: 80 | modify_account();break; 81 | case 7: 82 | close_account();break; 83 | case 8: 84 | break; 85 | default: 86 | printf("Incorrect Input"); 87 | } 88 | printf("Press any key to continue"); 89 | getch(); 90 | }while(ch!=8); 91 | } 92 | void open_account(){ 93 | FILE *fp; 94 | fp=fopen("bank.bin","rb"); 95 | if(fp==NULL){ 96 | c1.acno=0; 97 | } 98 | else{ 99 | while(1){ 100 | fread(&c1,sizeof(c1),1,fp); 101 | if(feof(fp)) 102 | break; 103 | } 104 | } 105 | c1.acno++; 106 | fclose(fp); 107 | printf("\n Enter name:"); 108 | fflush(stdin); 109 | gets(c1.name); 110 | while(1){ 111 | printf("Enter S for Saving and C for Current Account:"); 112 | fflush(stdin); 113 | scanf("%c",&c1.type); 114 | c1.type=toupper(c1.type); 115 | if(c1.type=='S' || c1.type=='C') 116 | break; 117 | else 118 | printf("\nInvalid input try again\n"); 119 | } 120 | printf("\n Enter initial amount to deposit min. 5000 for saving and 10000 for current:"); 121 | scanf("%f",&c1.bal); 122 | if(c1.type=='S' && c1.bal>=5000 || c1.type=='C' && c1.bal>=10000) 123 | { 124 | fp=fopen("bank.bin","ab"); 125 | if(fp==NULL) 126 | { 127 | printf("File opening error"); 128 | getch();exit(1); 129 | } 130 | fwrite(&c1,sizeof(c1),1,fp); 131 | printf("\n1 record successfully added\n"); 132 | printf("Your account number is %d\n",c1.acno); 133 | } 134 | else 135 | printf("\nInsufficient fund to open the account\n"); 136 | fclose(fp); 137 | } 138 | void deposit() 139 | { 140 | FILE *fp; 141 | int n,found; 142 | float amount; 143 | fp=fopen("bank.bin","rb+"); 144 | if(fp==NULL) 145 | { 146 | printf("File opening error"); 147 | getch();exit(1); 148 | } 149 | printf("\nEnter account number:"); 150 | scanf("%d",&n); 151 | found=0; 152 | while(1) 153 | { 154 | fread(&c1,sizeof(c1),1,fp); 155 | if(feof(fp)) 156 | break; 157 | if(c1.acno==n) 158 | { 159 | found=1; 160 | break; 161 | } 162 | } 163 | if(found==1) 164 | { 165 | printf("\nEnter amount to deposit:"); 166 | scanf("%f",&amount); 167 | c1.bal+=amount; 168 | printf("\nYour new balance is %.2f",c1.bal); 169 | fseek(fp,-sizeof(c1),SEEK_CUR); 170 | fwrite(&c1,sizeof(c1),1,fp); 171 | } 172 | else 173 | printf("\nInvalid account number"); 174 | fclose(fp); 175 | } 176 | void withdraw() 177 | { 178 | FILE *fp; 179 | int n,found; 180 | float amount; 181 | fp=fopen("bank.bin","rb+"); 182 | if(fp==NULL) 183 | { 184 | printf("\nFile opening error"); 185 | getch();exit(1); 186 | } 187 | printf("\nEnter account number:"); 188 | scanf("%d",&n); 189 | found=0; 190 | while(1) 191 | { 192 | fread(&c1,sizeof(c1),1,fp); 193 | if(feof(fp)) 194 | break; 195 | if(c1.acno==n) 196 | { 197 | found=1; 198 | break; 199 | } 200 | } 201 | if(found==1) 202 | { 203 | printf("\nEnter amount to withdraw:"); 204 | scanf("%f",&amount); 205 | if(c1.type=='S' && (c1.bal-amount)<5000 || c1.type=='C' && (c1.bal-amount)<10000) 206 | printf("\nInsufficient funds to withdraw"); 207 | else 208 | { 209 | c1.bal-=amount; 210 | printf("\nYour new balance is %.2f",c1.bal); 211 | fseek(fp,-sizeof(c1),SEEK_CUR); 212 | fwrite(&c1,sizeof(c1),1,fp); 213 | } 214 | } 215 | else 216 | printf("\nInvalid account number"); 217 | fclose(fp); 218 | } 219 | void show_balance() 220 | { 221 | FILE *fp; 222 | int n,found; 223 | float amount; 224 | fp=fopen("bank.bin","rb"); 225 | if(fp==NULL) 226 | { 227 | printf("\nFile opening error"); 228 | getch();exit(1); 229 | } 230 | printf("\nEnter account number:"); 231 | scanf("%d",&n); 232 | found=0; 233 | while(1) 234 | { 235 | fread(&c1,sizeof(c1),1,fp); 236 | if(feof(fp)) 237 | break; 238 | if(c1.acno==n) 239 | { 240 | found=1; 241 | break; 242 | } 243 | } 244 | if(found==1) 245 | { 246 | printf("\nYour balance is %.2f",c1.bal); 247 | } 248 | else 249 | printf("\nInvalid account number"); 250 | fclose(fp); 251 | } 252 | void show_all() 253 | { 254 | FILE *fp; 255 | int n; 256 | float amount; 257 | fp=fopen("bank.bin","rb"); 258 | if(fp==NULL) 259 | { 260 | printf("\nFile opening error"); 261 | getch();exit(1); 262 | } 263 | printf("\nAcno\tName\t\tBalance\n"); 264 | while(1) 265 | { 266 | fread(&c1,sizeof(c1),1,fp); 267 | if(feof(fp)) 268 | break; 269 | if(strlen(c1.name)>=8) 270 | printf("%d\t%s\t%.2f\n",c1.acno,c1.name,c1.bal); 271 | else 272 | printf("%d\t%s\t\t%.2f\n",c1.acno,c1.name,c1.bal); 273 | } 274 | fclose(fp); 275 | } 276 | void modify_account() 277 | { 278 | FILE *fp; 279 | int n,found; 280 | fp=fopen("bank.bin","rb+"); 281 | if(fp==NULL) 282 | { 283 | printf("\nFile opening error"); 284 | getch();exit(1); 285 | } 286 | printf("\nEnter account number:"); 287 | scanf("%d",&n); 288 | found=0; 289 | while(1) 290 | { 291 | fread(&c1,sizeof(c1),1,fp); 292 | if(feof(fp)) 293 | break; 294 | if(c1.acno==n) 295 | { 296 | found=1; 297 | break; 298 | } 299 | } 300 | if(found==1) 301 | { 302 | printf("\n Enter name:"); 303 | fflush(stdin); 304 | gets(c1.name); 305 | fseek(fp,-sizeof(c1),SEEK_CUR); 306 | fwrite(&c1,sizeof(c1),1,fp); 307 | } 308 | else 309 | printf("\nInvalid account number"); 310 | fclose(fp); 311 | } 312 | void close_account() 313 | { 314 | FILE *fp1,*fp2; 315 | int n,found; 316 | fp1=fopen("bank.bin","rb"); 317 | fp2=fopen("temp.bin","wb"); 318 | if(fp1==NULL || fp2==NULL) 319 | { 320 | printf("\nFile opening error"); 321 | getch();exit(1); 322 | } 323 | printf("\nEnter account number:"); 324 | scanf("%d",&n); 325 | found=0; 326 | while(1) 327 | { 328 | fread(&c1,sizeof(c1),1,fp1); 329 | if(feof(fp1)) 330 | break; 331 | if(c1.acno==n) 332 | { 333 | found=1; 334 | } 335 | else 336 | fwrite(&c1,sizeof(c1),1,fp2); 337 | } 338 | fclose(fp1); 339 | fclose(fp2); 340 | if(found==0) 341 | { 342 | printf("\nInvalid account number"); 343 | remove("temp.bin"); 344 | } 345 | else 346 | { 347 | remove("bank.bin"); 348 | rename("temp.bin","bank.bin"); 349 | printf("Record removed successfully"); 350 | } 351 | } 352 | void clrscr() 353 | { 354 | system("cls"); 355 | } 356 | 357 | 358 | 359 | 360 | 361 | -------------------------------------------------------------------------------- /Bank Management System/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Bank Management System 3 | * Bank management system project is a c programming based mini project. It has a command-line interface. It is useful for managing a bank account in a bank. 4 | 5 | * Bank management system is useful for managing bank account in a bank. It is a very useful software for maintaining account’s record. Although it has command line interface it is very easy to use and implement. The project performs CRUD operations without errors. 6 | 7 | * **It is password protected. The password to enter this system is “bank” (all with lower case).** 8 | * Hence, this project is just like real banking software with all basic features. 9 | 10 | * It doesn’t consist of high graphics. 11 | 12 | * It is the simple one and users can understand very easily. 13 | 14 | ## Execution Flow of the Program 15 | ## 1. Welcome Text 16 | When we execute the project code and after entering the above mentioned "Password" we will see some welcome text on screen. 17 | 18 | 19 | 20 | ## 2. Functions that can be Performed 21 | * We must press the enter key to get started. As we click the enter button we will reach the main menu screen. 22 | * From this screen, we will be able to use the function of the system. 23 | * The main menu has eight options. 24 | 25 | 26 | 27 | ## 3. Open New Account 28 | * The options are open new account, deposit, withdraw, show balance, account holder’s list, modify an account, close account and exit. 29 | * We must enter the number for selecting the options. 30 | * Select 1 to create new account. 31 | * We need to fill some information. Such as account no, account holder name, account type (current or saving), and balance. 32 | **Account created !!** 33 | 34 | 35 | 36 | ## 4. Deposit Money 37 | * The deposit option allows you to deposit money in your account. 38 | 39 | 40 | 41 | ## 5. Withdraw Money 42 | * Withdraw option allows you to take out money from your account. 43 | * You must provide the account number to withdraw. 44 | 45 | 46 | 47 | 48 | ## 6. Show Balance 49 | * The show balance shows current balance of the account. 50 | * You must provide the account number. 51 | 52 | 53 | 54 | ## 7. Show All Accounts 55 | * The show all displays all the people’s account information stored . 56 | 57 | 58 | 59 | ## 8. Modify Account 60 | * Further, you can modify your account if you get your wrong information. 61 | 62 | 63 | 64 | * After modification , details of accounts are :- 65 | 66 | 67 | 68 | ## 9. Close Account 69 | * You can also close an account or delete account. 70 | 71 | 72 | 73 | ## 10. Exit 74 | 75 | * After you finish your task you can easily exit from the system.   76 | 77 | 78 | 79 | This is how the system works. 80 | It is easy to understand the project code too. 81 | It uses bin file to store the information. 82 | Using this, we can easily create account and store the information. 83 | File handling is used to store the information. 84 | 85 | 86 | # All Done!! 87 | 88 | -------------------------------------------------------------------------------- /Bank Management System/images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Bank Management System/images/1.png -------------------------------------------------------------------------------- /Bank Management System/images/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Bank Management System/images/10.png -------------------------------------------------------------------------------- /Bank Management System/images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Bank Management System/images/2.png -------------------------------------------------------------------------------- /Bank Management System/images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Bank Management System/images/3.png -------------------------------------------------------------------------------- /Bank Management System/images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Bank Management System/images/4.png -------------------------------------------------------------------------------- /Bank Management System/images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Bank Management System/images/5.png -------------------------------------------------------------------------------- /Bank Management System/images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Bank Management System/images/6.png -------------------------------------------------------------------------------- /Bank Management System/images/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Bank Management System/images/7.png -------------------------------------------------------------------------------- /Bank Management System/images/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Bank Management System/images/8.png -------------------------------------------------------------------------------- /Bank Management System/images/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Bank Management System/images/9.png -------------------------------------------------------------------------------- /C Clock/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | # Project 1 (Terminal Clock⏰): 3 | 4 | Automatically runs the time in terminal, after user input the current time. 5 | ⭐⭐ 6 | 7 | https://user-images.githubusercontent.com/92109154/170866407-5ab45800-55b5-4b6b-b7e7-3c7747c8c304.mp4 8 | 9 | -------------------------------------------------------------------------------- /C Clock/clockAutomate.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void delay(int ss) 6 | { 7 | // Converting time into milli_seconds 8 | int milli_seconds = 1000 * ss; 9 | 10 | // Storing start time 11 | clock_t start_time = clock(); 12 | 13 | // looping till required time is not achieved 14 | while (clock() < start_time + milli_seconds) 15 | ; 16 | } 17 | int main() 18 | { 19 | int hh, mm, ss; 20 | printf("Enter current time in hour-minute-second format separeted by spaces : "); 21 | scanf("%d%d%d", &hh, &mm, &ss); 22 | while (1) 23 | { 24 | delay(1); 25 | ss++; 26 | if (ss == 60) 27 | { 28 | ss = 0; 29 | ss++; 30 | mm++; 31 | system("cls"); 32 | } 33 | if (mm == 60) 34 | { 35 | mm = 0; 36 | hh++; 37 | system("cls"); 38 | } 39 | 40 | if (hh == 24) 41 | { 42 | hh = 0; 43 | system("cls"); 44 | } 45 | printf("%d : %d : %d", hh, mm, ss); 46 | printf("\r"); 47 | } 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /C Clock/learn.md: -------------------------------------------------------------------------------- 1 | In this project, you will find a delay function that help the speed of iteration of any variable inside a loop by 1 second, next you see I use /r to take the cursor at the begining of the text and then I am priniting the time keeping while loop active for infinite. That's the project idea, hope you understand. 2 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | https://github.com/Rancho2002. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## How to contribute: 2 | 3 | ``` 4 | 1) Star ⭐ & fork the repo 5 | 2) Bring the repo in your local system 6 | 3) Create a new branch 7 | 4) Now create a directory(name of the directory should be the project name) 8 | 5) Add your C code projects along with readme.md ( ⚠️ VIDEO DEMO OR SCREENSHOTS everything uploaded inside readme not any other folder) so that your project can be easily understandable 9 | 6) Commit and create a pull request 10 | ``` 11 | Check this PR how did others do their successful PRs so that yours too can be merged instantly. 12 | https://github.com/Rancho2002/C-projects/pull/10 13 | 14 | 15 | 🥳🥳 and yaay!! You make your PR successfully.
16 | -------------------------------------------------------------------------------- /Calculator/Scientific Calculator.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | 10 | int main() { 11 | int choice, i, a, b; 12 | float x, y, result; 13 | printf("This is a Scientific Calculator\n"); 14 | do { 15 | printf("\nSelect your operation(0 to exit): \n"); 16 | printf("1. Addition\n2.Subtraction\n3.Multiplication\n4.Division\n"); 17 | printf("5. Square root\n6.X ^ Y\n7.X ^ 2\n8.X ^ 3\n"); 18 | printf("9. 1 / X\n10.X ^ (1 / Y)\n11.X ^ (1 / 3)\n"); 19 | printf("12. 10 ^ X\n13.X!\n14.Modulo\n15.log10(x)\n16.Modulus\n"); 20 | printf("17. Sin(X)\n18.Cos(X)\n19.Tan(X)\n20.Cosec(X)\n"); 21 | printf("21. Cot(X)\n22.Sec(X)\n"); 22 | printf("Choice: "); 23 | scanf("%d", & choice); 24 | if (choice == 0) exit(0); 25 | switch (choice) { 26 | case 1: 27 | printf("Enter X: "); 28 | scanf("%f", & x); 29 | printf("\nEnter Y: "); 30 | scanf("%f", & y); 31 | result = x + y; 32 | printf("\nResult: % f", result); 33 | break; 34 | case 2: 35 | printf("Enter X: "); 36 | scanf("%f", & x); 37 | printf("\nEnter Y: "); 38 | scanf("%f", & y); 39 | result = x-y; 40 | printf("\nResult:%f", result); 41 | break; 42 | case 3: 43 | printf("Enter X: "); 44 | scanf("%f", & x); 45 | printf("\nEnter Y: "); 46 | scanf("%f", & y); 47 | result = x * y; 48 | printf("\nResult:%f", result); 49 | break; 50 | case 4: 51 | printf("Enter X: "); 52 | scanf("%f", & x); 53 | printf("\nEnter Y: "); 54 | scanf("%f", & y); 55 | result = x / y; 56 | printf("\nResult:%f", result); 57 | break; 58 | case 5: 59 | printf("Enter X: "); 60 | scanf("%f", & x); 61 | result = sqrt(x); 62 | printf("\nResult:%f", result); 63 | break; 64 | case 6: 65 | printf("Enter X: "); 66 | scanf("%f", & x); 67 | printf("\nEnter Y: "); 68 | scanf("%f", & y); 69 | result = pow(x, y); 70 | printf("\nResult:%f", result); 71 | break; 72 | case 7: 73 | printf("Enter X: "); 74 | scanf("%f", & x); 75 | result = pow(x, 2); 76 | printf("\nResult:%f", result); 77 | break; 78 | case 8: 79 | printf("Enter X: "); 80 | scanf("%f", & x); 81 | result = pow(x, 3); 82 | printf("\nResult:%f", result); 83 | break; 84 | case 9: 85 | printf("Enter X: "); 86 | scanf("%f", & x); 87 | result = pow(x, -1); 88 | printf("\nResult:%f", result); 89 | break; 90 | case 10: 91 | printf("Enter X: "); 92 | scanf("%f", & x); 93 | printf("\nEnter Y: "); 94 | scanf("%f", & y); 95 | result = pow(x, (1 / y)); 96 | printf("\nResult:%f", result); 97 | break; 98 | case 11: 99 | printf("Enter X: "); 100 | scanf("%f", & x); 101 | y = 3; 102 | result = pow(x, (1 / y)); 103 | printf("\nResult:%f", result); 104 | break; 105 | case 12: 106 | printf("Enter X: "); 107 | scanf(" %f", & x); 108 | result = pow(10, x); 109 | printf("\nResult:%f", result); 110 | break; 111 | case 13: 112 | printf("Enter X: "); 113 | scanf("%f", & x); 114 | result = 1; 115 | for (i = 1; i <= x; i++) { 116 | result = result * i; 117 | } 118 | printf("\nResult: %.f", result); 119 | break; 120 | case 14: 121 | printf("Enter X: "); 122 | scanf("%f", & x); 123 | printf("\nEnter Y: "); 124 | scanf("%f", & y); 125 | result = (x * y) / 100; 126 | printf("\nResult: %.2f", result); 127 | break; 128 | case 15: 129 | printf("Enter X: "); 130 | scanf("%f", & x); 131 | result = log10(x); 132 | printf("\nResult: %.2f", result); 133 | break; 134 | case 16: 135 | printf("Enter X: "); 136 | scanf("%d", & a); 137 | printf("\nEnter Y: "); 138 | scanf("%d", & b); 139 | result = a % b; 140 | printf("\nResult:%.2f", result); 141 | break; 142 | case 17: 143 | printf("Enter X: "); 144 | scanf("%f", & x); 145 | result = sin(x * 3.14159 / 180); 146 | printf("\nResult: %.2f", result); 147 | break; 148 | case 18: 149 | printf("Enter X: "); 150 | scanf("%f", & x); 151 | result = cos(x * 3.14159 / 180); 152 | printf("\nResult: %.2f", result); 153 | break; 154 | case 19: 155 | printf("Enter X: "); 156 | scanf("%f", & x); 157 | result = tan(x * 3.14159 / 180); 158 | printf("\nResult: %.2f", result); 159 | break; 160 | case 20: 161 | printf("Enter X: "); 162 | scanf("%f", & x); 163 | result = 1 / (sin(x * 3.14159 / 180)); 164 | printf("\nResult: %.2f", result); 165 | break; 166 | case 21: 167 | printf("Enter X: "); 168 | scanf("%f", & x); 169 | result = 1 / tan(x * 3.14159 / 180); 170 | printf("\nResult: %.2f", result); 171 | break; 172 | case 22: 173 | printf("Enter X: "); 174 | scanf("%f", & x); 175 | result = 1 / cos(x * 3.14159 / 180); 176 | printf("\nResult: %.2f", result); 177 | break; 178 | default: 179 | printf("\nEnter Properly"); 180 | } 181 | } 182 | while (choice); 183 | getch(); 184 | return 0; 185 | } -------------------------------------------------------------------------------- /Calculator/readme.md: -------------------------------------------------------------------------------- 1 | Hello Guys 2 | 3 | ->So this code is a small miniproject for upcoming coders in which they ,ay or mightbe used in college 4 | 5 | So How to use? 6 | 7 | You can fork or download the repo, Once you have the file Scientific calculator.c u can run in the termial or in any idle (Eithier of your choice) 8 | 9 | 10 | Feel free to ask doubts and you can contact me if any changes are there 11 | 12 | 13 | 14 | https://user-images.githubusercontent.com/110409408/194894811-14b76562-afff-46ff-a5c0-9d9c630727bf.mp4 15 | 16 | -------------------------------------------------------------------------------- /Calendar With C/Readme.md: -------------------------------------------------------------------------------- 1 | #Project Name - Calendar Using C 2 | This is the project written purely in the C Language! 3 | 4 | Just Enter The Year whose calendar you want to see, and it will get displayed. 5 | 6 | Here's The Demo Link For The Project: 7 | https://www.youtube.com/watch?v=goynjvkXR5A -------------------------------------------------------------------------------- /Calendar With C/calendar.c: -------------------------------------------------------------------------------- 1 | #include 2 | int daysIN_month[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 3 | char *months[]= 4 | { 5 | " ", 6 | "\n\n\nJanuary", 7 | "\n\n\nFebruary", 8 | "\n\n\nMarch", 9 | "\n\n\nApril", 10 | "\n\n\nMay", 11 | "\n\n\nJune", 12 | "\n\n\nJuly", 13 | "\n\n\nAugust", 14 | "\n\n\nSeptember", 15 | "\n\n\nOctober", 16 | "\n\n\nNovember", 17 | "\n\n\nDecember" 18 | }; 19 | 20 | 21 | int determinedaycode(int year) 22 | { 23 | int daycode; 24 | int d1, d2, d3; 25 | 26 | d1 = (year - 1.)/ 4.0; 27 | d2 = (year - 1.)/ 100.; 28 | d3 = (year - 1.)/ 400.; 29 | daycode = (year + d1 - d2 + d3) %7; 30 | return daycode; 31 | } 32 | 33 | 34 | int getleapyear(int year) 35 | { 36 | if(year%4==0&&year%100!=0||year%400==0) 37 | { 38 | daysIN_month[2]=29; 39 | return 1; //obviously 40 | } 41 | else 42 | { 43 | daysIN_month[2] = 28; 44 | return 0; 45 | } 46 | } 47 | 48 | void calendar(int year, int daycode) 49 | { 50 | int month, day; 51 | for ( month = 1; month <= 12; month++ ) 52 | { 53 | printf("%s", months[month]); 54 | printf("\n\nSun Mon Tue Wed Thu Fri Sat\n" ); 55 | 56 | for (day=1;day<=1+daycode*5;day++) 57 | { 58 | printf(" "); 59 | } 60 | for(day=1;day<=daysIN_month[month];day++ ) 61 | { 62 | printf("%2d", day ); 63 | 64 | if((day+daycode)%7>0) 65 | printf(" " ); 66 | else 67 | printf("\n " ); 68 | } 69 | daycode = ( daycode + daysIN_month[month] ) % 7; 70 | } 71 | } 72 | 73 | int main() 74 | { 75 | int year, daycode, leapyear; 76 | printf("Please enter a year to get the calendar"); 77 | scanf("%d", &year); 78 | 79 | daycode = determinedaycode(year); 80 | getleapyear(year); 81 | printf("\nCalendar %d",year); 82 | calendar(year, daycode); 83 | printf("\n"); 84 | } 85 | -------------------------------------------------------------------------------- /Employee-Management-System/Employee Management System-github.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define Employee struct emp 7 | 8 | void add(FILE * fp); //to add to list 9 | FILE * del(FILE * fp);//to delete from list 10 | void modify(FILE * fp);//to modify a record 11 | void displayList(FILE * fp);//display whole list 12 | void searchRecord(FILE *fp);//find a particular record 13 | void printChar(char ch,int n);//printing a character ch n times 14 | void printHead(); 15 | 16 | 17 | struct emp 18 | { 19 | int id; 20 | char name[100]; 21 | char desgn[10]; 22 | float sal; 23 | char jdate[8]; 24 | char gender[10]; 25 | char branch[50]; 26 | char psaddr[200]; 27 | char prtaddr[200]; 28 | char phone[15]; 29 | char mail[20]; 30 | }; 31 | 32 | 33 | int main() 34 | { 35 | FILE * fp; 36 | Employee e; 37 | int option; 38 | char another; 39 | 40 | if((fp=fopen("employeeInfo.txt","rb+"))==NULL) 41 | { 42 | if((fp=fopen("employeeInfo.txt","wb+"))==NULL) 43 | { 44 | printf("can't open file"); 45 | return 0; 46 | } 47 | } 48 | char username[10],password[10]; 49 | printHead(); 50 | welcome(); 51 | printHead(); 52 | printf("\n\t\t\t\t Login Screen"); 53 | printf("\n\t\t\t Enter Your Credential"); 54 | printf("\n\n\n\t\tUsername: "); 55 | scanf("%s",username); 56 | printf("\n\t\tPassword: "); 57 | int i; 58 | i=0; 59 | do 60 | { 61 | password[i] = getch(); 62 | if(password[i] == 13 ) 63 | { 64 | break; 65 | } 66 | else if(password[i]==8 && i>0) 67 | { 68 | printf("%c%c%c",8,32,8); 69 | i--; 70 | } 71 | else 72 | { 73 | printf("*"); 74 | i++; 75 | } 76 | }while(password[i]!=13); 77 | password[i] = '\0'; 78 | 79 | if(((strcasecmp(username,"admin"))==0)&&((strcasecmp(password,"pass")==0))) 80 | { 81 | while(1) 82 | { 83 | printHead(); 84 | printf("\n\t\t\t\tMain Menu"); 85 | printf("\n\n\n"); 86 | 87 | 88 | printf("\n\n\t\t\t1. Add Employee"); 89 | printf("\n\n\t\t\t2. Delete Employee"); 90 | printf("\n\n\t\t\t3. Modify Employee"); 91 | printf("\n\n\t\t\t4. Display Employee List"); 92 | printf("\n\n\t\t\t5. Search Record"); 93 | printf("\n\n\t\t\t6. Display Basic Info"); 94 | printf("\n\n\t\t\t7. Display Basic Contact Info"); 95 | printf("\n\n\t\t\t8. List of Male Employee"); 96 | printf("\n\n\t\t\t9. List of Female Employee"); 97 | printf("\n\n\t\t\t10. List of Employee From Dhaka"); 98 | printf("\n\n\t\t\t11. List of Employee From Others District"); 99 | printf("\n\n\t\t\t12. List of Employee of Main Branch"); 100 | printf("\n\n\t\t\t13. List of Employee of Others Branch"); 101 | printf("\n\n\t\t\t0. EXIT"); 102 | 103 | printf("\n\n\t\tEnter Your Option :--> "); 104 | scanf("%d",&option); 105 | 106 | switch(option) 107 | { 108 | case 0: return 1; 109 | break; 110 | case 1: add(fp); 111 | break; 112 | case 2: fp=del(fp); 113 | break; 114 | case 3: modify(fp); 115 | break; 116 | case 4: displayList(fp); 117 | break; 118 | case 5: searchRecord(fp); 119 | break; 120 | case 6: displaybasic(fp); 121 | break; 122 | case 7: basiccontact(fp); 123 | break; 124 | case 8: maleemp(fp); 125 | break; 126 | case 9: femaleemp(fp); 127 | break; 128 | case 10: frmdhaka(fp); 129 | break; 130 | case 11: frmors(fp); 131 | break; 132 | case 12: mainbr(fp); 133 | break; 134 | case 13: otherbr(fp); 135 | break; 136 | default: printf("\n\t\tYou Pressed wrong key"); 137 | printf("\n\t\tProgram terminated"); 138 | getch(); 139 | exit(0); 140 | 141 | } 142 | } 143 | } 144 | else { 145 | printf("\n\t\tLogin Failed"); 146 | } 147 | 148 | 149 | return 1; 150 | 151 | } 152 | 153 | //====Welcome Screen===== 154 | void welcome() 155 | { 156 | printf("\n\n\n\n\n\t\t[ [ [ WELCOME TO OUR EMPLOYEE MANAGEMENT SYSTEM ] ] ]\n\n\n\n\n\n\n\t"); 157 | system("pause"); 158 | } 159 | 160 | 161 | //----printing character ch at n times ------ 162 | 163 | void printChar(char ch,int n) 164 | { 165 | while(n--) 166 | { 167 | putchar(ch); 168 | } 169 | } 170 | 171 | //-----Printing Head Line of the program ----- 172 | 173 | void printHead() 174 | { system("cls"); 175 | printf("\t"); 176 | printChar('=',65); 177 | printf("\n\t"); 178 | printChar('=',16); 179 | printf("[EMPLOYEE] [MANAGEMENT] [SYSTEM]"); 180 | printChar('=',16); 181 | printf("\n\t"); 182 | printChar('=',65); 183 | 184 | } 185 | 186 | 187 | // ==========ADDING NEW RECORD========================== 188 | 189 | void add(FILE * fp) 190 | { 191 | printHead(); 192 | 193 | printf("\n\t\t\t\Add Employee"); 194 | char another='y'; 195 | Employee e; 196 | 197 | fseek(fp,0,SEEK_END); 198 | while(another=='y'||another=='Y') 199 | { 200 | printf("\n\n\t\tEnter ID number: "); 201 | scanf("%d",&e.id); 202 | 203 | printf("\n\n\t\tEnter Full Name of Employee: "); 204 | fflush(stdin); 205 | fgets(e.name,100,stdin); //fgets takes an extra \n character as input 206 | e.name[strlen(e.name)-1]='\0'; 207 | 208 | 209 | printf("\n\n\t\tEnter Designation: "); 210 | fflush(stdin); 211 | fgets(e.desgn,10,stdin); //fgets takes an extra \n character as input 212 | e.desgn[strlen(e.desgn)-1]='\0'; 213 | 214 | 215 | printf("\n\n\t\tEnter Gender: "); 216 | fflush(stdin); 217 | fgets(e.gender,10,stdin); //fgets takes an extra \n character as input 218 | e.gender[strlen(e.gender)-1]='\0'; 219 | 220 | printf("\n\n\t\tEnter Branch: "); 221 | fflush(stdin); 222 | fgets(e.branch,50,stdin); 223 | e.branch[strlen(e.branch)-1]='\0'; 224 | 225 | 226 | printf("\n\n\t\tEnter Salary: "); 227 | scanf("%f",&e.sal); 228 | 229 | printf("\n\n\t\tEnter Present Address: "); 230 | fflush(stdin); 231 | fgets(e.psaddr,200,stdin); 232 | e.psaddr[strlen(e.psaddr)-1]='\0'; 233 | 234 | printf("\n\n\t\tEnter Permanant Address: "); 235 | fflush(stdin); 236 | fgets(e.prtaddr,200,stdin); 237 | e.prtaddr[strlen(e.prtaddr)-1]='\0'; 238 | 239 | printf("\n\n\t\tEnter Phone: "); 240 | fflush(stdin); 241 | fgets(e.phone,50,stdin); 242 | e.phone[strlen(e.phone)-1]='\0'; 243 | 244 | printf("\n\n\t\tEnter E-mail: "); 245 | fflush(stdin); 246 | fgets(e.mail,20,stdin); 247 | e.mail[strlen(e.mail)-1]='\0'; 248 | 249 | fwrite(&e,sizeof(e),1,fp); 250 | 251 | printf("\n\n\t\tWant to enter another employee info (Y/N)\t"); 252 | fflush(stdin); 253 | another=getchar(); 254 | } 255 | } 256 | 257 | 258 | //===================DELETING A RECORD FROM LIST ============ 259 | FILE * del(FILE * fp) 260 | { 261 | printHead(); 262 | printf("\n\t\t\t\Delete Employee"); 263 | Employee e; 264 | int flag=0,tempid,siz=sizeof(e); 265 | FILE *ft; 266 | 267 | if((ft=fopen("temp.txt","wb+"))==NULL) 268 | { 269 | printf("\n\n\t\t\t\\t!!! ERROR !!!\n\t\t"); 270 | system("pause"); 271 | return fp; 272 | } 273 | 274 | printf("\n\n\tEnter ID number of Employee to Delete the Record"); 275 | printf("\n\n\t\t\tID No. : "); 276 | scanf("%d",&tempid); 277 | 278 | rewind(fp); 279 | 280 | 281 | while((fread(&e,siz,1,fp))==1) 282 | { 283 | if(e.id==tempid) 284 | { flag=1; 285 | printf("\n\tRecord Deleted for"); 286 | printf("\n\n\t\t%s\n\n\t\t%s\n\n\t\t%d\n\t",e.name,e.branch,e.id); 287 | continue; 288 | } 289 | 290 | fwrite(&e,siz,1,ft); 291 | } 292 | 293 | 294 | fclose(fp); 295 | fclose(ft); 296 | 297 | remove("employeeInfo.txt"); 298 | rename("temp.txt","employeeInfo.txt"); 299 | 300 | if((fp=fopen("employeeInfo.txt","rb+"))==NULL) 301 | { 302 | printf("ERROR"); 303 | return NULL; 304 | } 305 | 306 | if(flag==0) printf("\n\n\t\t!!!! ERROR RECORD NOT FOUND \n\t"); 307 | 308 | printChar('-',65); 309 | printf("\n\t"); 310 | system("pause"); 311 | return fp; 312 | } 313 | 314 | 315 | //===========MODIFY A RECORD =========================== 316 | 317 | void modify(FILE * fp) 318 | { 319 | printHead(); 320 | printf("\n\t\t\t\Modify Employee"); 321 | Employee e; 322 | int i,flag=0,tempid,siz=sizeof(e); 323 | float sal; 324 | 325 | printf("\n\n\tEnter ID Number of Employee to Modify the Record : "); 326 | scanf("%d",&tempid); 327 | 328 | rewind(fp); 329 | 330 | while((fread(&e,siz,1,fp))==1) 331 | { 332 | if(e.id==tempid) 333 | {flag=1; 334 | break; 335 | } 336 | } 337 | 338 | if(flag==1) 339 | { 340 | fseek(fp,-siz,SEEK_CUR); 341 | printf("\n\n\t\tRecord Found"); 342 | printf("\n\n\t\tEnter New Data for the Record"); 343 | 344 | printf("\n\n\t\tEnter ID number: "); 345 | scanf("%d",&e.id); 346 | 347 | printf("\n\n\t\tEnter Full Name of Employee: "); 348 | fflush(stdin); 349 | fgets(e.name,100,stdin); //fgets takes an extra \n character as input 350 | e.name[strlen(e.name)-1]='\0'; 351 | 352 | 353 | printf("\n\n\t\tEnter Designation: "); 354 | fflush(stdin); 355 | fgets(e.desgn,10,stdin); //fgets takes an extra \n character as input 356 | e.desgn[strlen(e.desgn)-1]='\0'; 357 | 358 | 359 | printf("\n\n\t\tEnter Gender: "); 360 | fflush(stdin); 361 | fgets(e.gender,10,stdin); //fgets takes an extra \n character as input 362 | e.gender[strlen(e.gender)-1]='\0'; 363 | 364 | printf("\n\n\t\tEnter Branch: "); 365 | fflush(stdin); 366 | fgets(e.branch,50,stdin); 367 | e.branch[strlen(e.branch)-1]='\0'; 368 | 369 | 370 | printf("\n\n\t\tEnter Salary: "); 371 | scanf("%f",&e.sal); 372 | 373 | printf("\n\n\t\tEnter Present Address: "); 374 | fflush(stdin); 375 | fgets(e.psaddr,200,stdin); 376 | e.psaddr[strlen(e.psaddr)-1]='\0'; 377 | 378 | printf("\n\n\t\tEnter Permanant Address: "); 379 | fflush(stdin); 380 | fgets(e.prtaddr,200,stdin); 381 | e.prtaddr[strlen(e.prtaddr)-1]='\0'; 382 | 383 | printf("\n\n\t\tEnter Phone: "); 384 | fflush(stdin); 385 | fgets(e.phone,50,stdin); 386 | e.phone[strlen(e.phone)-1]='\0'; 387 | 388 | printf("\n\n\t\tEnter E-mail: "); 389 | fflush(stdin); 390 | fgets(e.mail,20,stdin); 391 | e.mail[strlen(e.mail)-1]='\0'; 392 | 393 | fwrite(&e,sizeof(e),1,fp); 394 | } 395 | 396 | else printf("\n\n\t!!!! ERROR !!!! RECORD NOT FOUND"); 397 | 398 | printf("\n\n\t"); 399 | system("pause"); 400 | 401 | } 402 | 403 | //====================DISPLAY THE LIST ================= 404 | void displayList(FILE * fp) 405 | { printHead(); 406 | printf("\n\t\t\t\List of Employees"); 407 | Employee e; 408 | int i,siz=sizeof(e); 409 | 410 | rewind(fp); 411 | 412 | while((fread(&e,siz,1,fp))==1) 413 | { 414 | printf("\n\n\t\tID : %d",e.id); 415 | printf("\n\n\t\tNAME : %s",e.name); 416 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 417 | printf("\n\n\t\tGENDER : %s",e.gender); 418 | printf("\n\n\t\tBRANCH : %s",e.branch); 419 | printf("\n\n\t\tSALARY : %.2f",e.sal); 420 | printf("\n\n\t\tPRESENT ADDRESS : %s",e.psaddr); 421 | printf("\n\n\t\tPERMANANT ADDRESS : %s",e.prtaddr); 422 | printf("\n\n\t\tPHONE : %s",e.phone); 423 | printf("\n\n\t\tE-MAIL : %s\n\n\t",e.mail); 424 | printChar('=',65); 425 | } 426 | printf("\n\n\n\t"); 427 | printf("\n\n\t"); 428 | system("pause"); 429 | } 430 | 431 | 432 | //================SEARCH EMPLOYEE== 433 | void searchRecord(FILE *fp) 434 | {printHead(); 435 | printf("\n\t\t\t\Search Employee"); 436 | int tempid,flag,siz,i; 437 | Employee e; 438 | char another='y'; 439 | 440 | siz=sizeof(e); 441 | 442 | while(another=='y'||another=='Y') 443 | { 444 | printf("\n\n\tEnter ID Number of Employee to search the record : "); 445 | scanf("%d",&tempid); 446 | 447 | rewind(fp); 448 | 449 | while((fread(&e,siz,1,fp))==1) 450 | { 451 | if(e.id==tempid) 452 | {flag=1; 453 | break; 454 | } 455 | } 456 | 457 | if(flag==1) 458 | { 459 | printf("\n\t\tNAME : %s",e.name); 460 | printf("\n\n\t\tID : %d",e.id); 461 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 462 | printf("\n\n\t\tBRANCH : %s",e.branch); 463 | printf("\n\n\t\tSALARY: %.2f",e.sal); 464 | printf("\n\n\t\tPRESENT ADDRESS : %s",e.psaddr); 465 | printf("\n\n\t\tPERMANANT ADDRESS : %s",e.prtaddr); 466 | printf("\n\n\t\tPHONE : %s",e.phone); 467 | printf("\n\n\t\tE-MAIL : %s",e.mail); 468 | 469 | printChar('=',65); 470 | 471 | } 472 | else printf("\n\n\t\t!!!! ERROR RECORD NOT FOUND !!!!"); 473 | 474 | 475 | printf("\n\n\t\tWant to enter another search (Y/N)"); 476 | fflush(stdin); 477 | another=getchar(); 478 | } 479 | } 480 | 481 | //========================LIST OF MALE EMPLOYEE== 482 | void maleemp(FILE * fp) 483 | { 484 | printHead(); 485 | printf("\n\t\t\t\List of Male Employee"); 486 | Employee e; 487 | int i,siz=sizeof(e); 488 | 489 | rewind(fp); 490 | 491 | while((fread(&e,siz,1,fp))==1) 492 | { 493 | if((strcmp(e.gender,"Male")==0)||(strcmp(e.gender,"male")==0)) 494 | { 495 | 496 | printf("\n\n\t\tID : %d",e.id); 497 | printf("\n\n\t\tNAME : %s",e.name); 498 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 499 | printf("\n\n\t\tPHONE : %s",e.phone); 500 | printChar('-',65); 501 | } 502 | } 503 | printf("\n\n\n\t"); 504 | printChar('*',65); 505 | printf("\n\n\t"); 506 | system("pause"); 507 | } 508 | 509 | 510 | //========================LIST OF FEMALE EMPLOYEE== 511 | 512 | void femaleemp(FILE * fp) 513 | { 514 | printHead(); 515 | printf("\n\t\t\t\List of Female Employee"); 516 | Employee e; 517 | int i,siz=sizeof(e); 518 | 519 | rewind(fp); 520 | 521 | while((fread(&e,siz,1,fp))==1) 522 | { 523 | if((strcmp(e.gender,"Female")==0)||(strcmp(e.gender,"female")==0)) 524 | { 525 | printf("\n\n\t\tID : %d",e.id); 526 | printf("\n\n\t\tNAME : %s",e.name); 527 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 528 | printf("\n\n\t\tPHONE : %s",e.phone); 529 | printChar('-',65); 530 | } 531 | } 532 | printf("\n\n\n\t"); 533 | printChar('*',65); 534 | printf("\n\n\t"); 535 | system("pause"); 536 | } 537 | 538 | //========================LIST OF EMPLOYEE FROM DHAKA==== 539 | 540 | void frmdhaka(FILE * fp) 541 | { 542 | printHead(); 543 | printf("\n\t\t\t\List of Employee From Dhaka"); 544 | Employee e; 545 | int i,siz=sizeof(e); 546 | 547 | rewind(fp); 548 | 549 | while((fread(&e,siz,1,fp))==1) 550 | { 551 | if((strstr(e.prtaddr,"Dhaka")==0)||(strstr(e.prtaddr,"dhaka")==0)||(strstr(e.prtaddr,"DHAKA")==0)) 552 | { 553 | printf("\n\n\t\tID : %d",e.id); 554 | printf("\n\n\t\tNAME : %s",e.name); 555 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 556 | printf("\n\n\t\tPHONE : %s",e.phone); 557 | printf("\n\n\t\tE-MAIL : %s",e.mail); 558 | printChar('=',65); 559 | } 560 | } 561 | printf("\n\n\n\t"); 562 | printf("\n\n\t"); 563 | system("pause"); 564 | } 565 | 566 | //========================LIST OF EMPLOYEE FROM ORS DIST==== 567 | 568 | void frmors(FILE * fp) 569 | { 570 | printHead(); 571 | printf("\n\t\t\t\List of Employee From Others District"); 572 | Employee e; 573 | int i,siz=sizeof(e); 574 | 575 | rewind(fp); 576 | 577 | while((fread(&e,siz,1,fp))==1) 578 | { 579 | if((strstr(e.prtaddr,"Dhaka")==1)&&(strstr(e.prtaddr,"dhaka")==1)&&(strstr(e.prtaddr,"DHAKA")==1)) 580 | { 581 | printf("\n\n\t\tID : %d",e.id); 582 | printf("\n\n\t\tNAME : %s",e.name); 583 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 584 | printf("\n\n\t\tPHONE : %s",e.phone); 585 | printf("\n\n\t\tE-MAIL : %s",e.mail); 586 | printChar('=',65); 587 | } 588 | } 589 | printf("\n\n\n\t"); 590 | printf("\n\n\t"); 591 | system("pause"); 592 | } 593 | 594 | //==============DISPLAY BASIC INFO LIST== 595 | 596 | void displaybasic(FILE * fp) 597 | { printHead(); 598 | printf("\n\t\t\t\Display Basic Information"); 599 | Employee e; 600 | int i,siz=sizeof(e); 601 | 602 | rewind(fp); 603 | 604 | while((fread(&e,siz,1,fp))==1) 605 | { 606 | printf("\n\n\t\tID : %d",e.id); 607 | printf("\n\n\t\tNAME : %s",e.name); 608 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 609 | printf("\n\n\t\tGENDER : %s",e.gender); 610 | printf("\n\n\t\tBRANCH : %s",e.branch); 611 | printf("\n\n\t\tPHONE : %s",e.phone); 612 | printf("\n\n\t\tE-MAIL : %s\n\n\t",e.mail); 613 | printChar('=',65); 614 | } 615 | printf("\n\n\n\t"); 616 | printf("\n\n\t"); 617 | system("pause"); 618 | } 619 | 620 | //========BASIC CONTACT INFO LIST==== 621 | 622 | void basiccontact(FILE * fp) 623 | { printHead(); 624 | printf("\n\t\t\t\Basic Contact Information"); 625 | Employee e; 626 | int i,siz=sizeof(e); 627 | 628 | rewind(fp); 629 | 630 | while((fread(&e,siz,1,fp))==1) 631 | { 632 | printf("\n\n\t\tID : %d",e.id); 633 | printf("\n\n\t\tNAME : %s",e.name); 634 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 635 | printf("\n\n\t\tPHONE : %s",e.phone); 636 | printf("\n\n\t\tE-MAIL : %s\n\n\t",e.mail); 637 | printChar('=',65); 638 | } 639 | printf("\n\n\n\t"); 640 | printf("\n\n\t"); 641 | system("pause"); 642 | } 643 | 644 | 645 | //========================LIST OF EMPLOYEE OF MAIN BRANCH==== 646 | 647 | void mainbr(FILE * fp) 648 | { 649 | printHead(); 650 | printf("\n\t\t\t\List of Employee of Main Branch"); 651 | Employee e; 652 | int i,siz=sizeof(e); 653 | 654 | rewind(fp); 655 | 656 | while((fread(&e,siz,1,fp))==1) 657 | { 658 | if((strcmp(e.branch,"Main")==0)||(strcmp(e.prtaddr,"main")==0)||(strcmp(e.prtaddr,"MAIN")==0)) 659 | { 660 | printf("\n\n\t\tID : %d",e.id); 661 | printf("\n\n\t\tNAME : %s",e.name); 662 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 663 | printf("\n\n\t\tPHONE : %s",e.phone); 664 | printf("\n\n\t\tE-MAIL : %s\n\t",e.mail); 665 | printChar('=',65); 666 | } 667 | } 668 | printf("\n\n\n\t"); 669 | printf("\n\n\t"); 670 | system("pause"); 671 | } 672 | 673 | //========================LIST OF EMPLOYEE OF OTHRES BRANCH==== 674 | 675 | void otherbr(FILE * fp) 676 | { 677 | printHead(); 678 | printf("\n\t\t\t\List of Employee of Other Branch"); 679 | Employee e; 680 | int i,siz=sizeof(e); 681 | 682 | rewind(fp); 683 | 684 | while((fread(&e,siz,1,fp))==1) 685 | { 686 | if((strcmp(e.branch,"Main")!=0)&&(strcmp(e.prtaddr,"main")!=0)&&(strcmp(e.prtaddr,"MAIN")!=0)) 687 | { 688 | printf("\n\n\t\tID : %d",e.id); 689 | printf("\n\n\t\tNAME : %s",e.name); 690 | printf("\n\n\t\tDESIGNATION : %s",e.desgn); 691 | printf("\n\n\t\tPHONE : %s",e.phone); 692 | printf("\n\n\t\tE-MAIL : %s\n\n\t",e.mail); 693 | printChar('=',65); 694 | } 695 | } 696 | printf("\n\n\n\t"); 697 | printf("\n\n\t"); 698 | system("pause"); 699 | } 700 | -------------------------------------------------------------------------------- /Employee-Management-System/README.md: -------------------------------------------------------------------------------- 1 | # EMS-C-Project 2 | Employee Management System in C Fully Based in Terminal a Simple but most relevant project of mine. 3 | 4 | 5 | Link of Project Demo: https://vimeo.com/759187577 6 | 7 | INTRODUCTION: 8 | What is EMS? 9 | # Employee Management System is a distributed application, developed to maintain the details of employees working in any organization. 10 | # The EMS has been developed to override the problems prevailing in the practicing manual system. 11 | # It maintains the information about the personal and official details of the employees. 12 | 13 | 14 | 15 | 16 | OBJECTIVES OF OUR PROJECT: 17 | # This project aims to simplify the task of maintaining records of the employees of Company. 18 | # To develop an well-designed database to store employee information. 19 | # Provides full functional reports to management of Company. 20 | # The objective of this project is to provide a comprehensive approach towards the management of employee information. 21 | 22 | 23 | 24 | FEATURES : 25 | # Proper Login Screen (Invisible Password Typing). 26 | # Password Protected. 27 | # Encrypted File (Binary). 28 | # Easily Add, Delete, Modify Records. 29 | # Various Essential Queries. 30 | -------------------------------------------------------------------------------- /Grep_Project/Makefile: -------------------------------------------------------------------------------- 1 | run : grep.o mystrtok_multi.o mystrstr.o mystrstrcase.o dir.o usage.o standard_input.o standard_options.o 2 | gcc -Wall -o project *.o 3 | grep : grep.c header.h 4 | gcc -c grep.c 5 | tok : mystrtok_multi.c header.h 6 | gcc -c mystrtok_multi.c 7 | str : mystrstr.c mystrstrcase.c header.h 8 | gcc -c mystrstr.c mystrstrcase.c 9 | dir : dir.c header.h 10 | gcc -c dir.c 11 | usage : usage.c header.h 12 | gcc -c usage.c 13 | stdi : standard_input.c header.h 14 | gcc -c standard_input.c 15 | stdo : standard_options.c header.h 16 | gcc -c standard_options.c 17 | clean : 18 | rm *.o 19 | -------------------------------------------------------------------------------- /Grep_Project/README.md: -------------------------------------------------------------------------------- 1 | 2 | **** Sushant Agawane ****
3 | **** 111708004 ****
4 | # Grep 5 | The Grep command in Linux.
6 | Usage: ./project [OPTION] PATTERN [FILE]...
7 | Search for PATTERN in each file.
8 | For help : ./project -h
9 | For standard input : ./project PATTERN
10 | For standard input with options : ./project [OPTION] PATTERN
11 | *****************************************************
12 | The Program uses mystrtok and mystrstr functions to find the pattern and print the lines containing the pattern.
13 | mystrtok divides the file content into single lines and seearches for the pattern.
14 | mystrstr searches for the pattern and then prints the line if the pattern is found.
15 | Various options implemented are shown in ./project -h.
16 | -r option which traverses through directories. It is implemented in dir.c. dirent.h is used to do so.
17 | mystrstrcase function ignores case to search pattern.
18 | 19 | 20 | 21 | # Video Demo 22 | https://drive.google.com/file/d/1GiyVUBoS-PcvLHXmwlFm1mTVCkfcNzMS/view?usp=sharing 23 | -------------------------------------------------------------------------------- /Grep_Project/Screenshots/A.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/A.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/H.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/H.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/L.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/L.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/Li.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/Li.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/b.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/c.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/cv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/cv.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/h.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/help.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/i.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/i.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/in.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/l.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/li.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/li.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/m.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/n.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/normal.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/r.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/ri.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/ri.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/rv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/rv.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/standard_i.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/standard_i.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/standard_input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/standard_input.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/standard_v.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/standard_v.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/standard_vi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/standard_vi.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/v.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/v.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/vn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/vn.png -------------------------------------------------------------------------------- /Grep_Project/Screenshots/w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Grep_Project/Screenshots/w.png -------------------------------------------------------------------------------- /Grep_Project/dir.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "header.h" 13 | #include 14 | void recursive(char *dname, char *search, int FLAG) { 15 | int f[6], size[6], i = 0; 16 | char *a; 17 | char s[2] = "\n"; 18 | char *token; 19 | DIR *dir; 20 | dir=opendir(dname); 21 | struct dirent *dent; 22 | if(dir!=NULL) { 23 | while((dent = readdir(dir))) { 24 | if(dent->d_type == DT_DIR) { 25 | if(strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0); 26 | else { 27 | strcat(dname, "/"); 28 | strcat(dname, dent->d_name); 29 | if(FLAG == 0) 30 | recursive(dname, search, 0); 31 | else if(FLAG == 1) 32 | recursive(dname, search, 1); 33 | else if(FLAG == 2) 34 | recursive(dname, search, 2); 35 | } 36 | } 37 | else if(f[i] = open(dent->d_name, O_RDONLY)) { 38 | size[i] = lseek(f[i], 0, SEEK_END); 39 | a = (char*)malloc(size[i]*sizeof(char)); 40 | lseek(f[i], 0, 0); 41 | read(f[i], a, size[i]*sizeof(char)); 42 | token = strtok(a, s); 43 | while( token != NULL ) { 44 | if((mystrstr( token, search) != NULL && FLAG == 0) || (mystrstrcase(token, search) != NULL && FLAG == 1) || (mystrstr(token, search) == NULL && FLAG == 2)) { 45 | printf("%s%s/%s%s:%s%s\n", KMAG, dname, dent->d_name, KBLU, KNRM, token); 46 | } 47 | token = strtok(NULL, s); 48 | } 49 | close(f[i]); 50 | free (a); 51 | } 52 | i++; 53 | } 54 | closedir(dir); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Grep_Project/grep.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "header.h" 14 | int main(int argc, char *argv[]) { 15 | int f[10], size[10], i = 0; 16 | char *a; 17 | char s[2] = "\n"; 18 | char *token; 19 | if(argc == 1) { 20 | printf("Use ./project -h command for usage\n"); 21 | exit(1); 22 | } 23 | else if(strcmp(argv[1],"-h") == 0 && argv[2] == NULL) { 24 | usage(); 25 | exit(1); 26 | } 27 | if(argc < 3 && strcmp(argv[0], "./project") != 0) { 28 | errno = EINVAL; 29 | perror("Bad arguments"); 30 | return errno; 31 | } 32 | else if(argc < 3 || (argc < 4 && argv[1][0] == '-')) { 33 | if(argc < 3) 34 | standard_input(argv[1]); 35 | if(argc < 4) 36 | standard_options(argv[1], argv[2]); 37 | exit(1); 38 | } 39 | if(strcmp(argv[1],"-r") == 0 || strcmp(argv[1], "-ri") == 0 || strcmp(argv[1], "-rv") == 0) { 40 | DIR *dir; 41 | char dname[32]; 42 | dir = opendir(argv[3]); 43 | struct dirent *dent; 44 | if(dir!=NULL) { 45 | while((dent = readdir(dir))) { 46 | if(dent->d_type == DT_DIR) { 47 | if(strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0); 48 | else { 49 | strcpy(dname, argv[3]); 50 | strcat(dname, "/"); 51 | strcat(dname, dent->d_name); 52 | if(strcmp(argv[1], "-r") == 0) 53 | recursive(dname, argv[2], 0); 54 | if(strcmp(argv[1], "-ri") == 0) 55 | recursive(dname, argv[2], 1); 56 | if(strcmp(argv[1], "-rv") == 0) 57 | recursive(dname, argv[2], 2); 58 | } 59 | } 60 | else if(f[i] = open(dent->d_name, O_RDONLY)) { 61 | size[i] = lseek(f[i], 0, SEEK_END); 62 | a = (char*)malloc(size[i]*sizeof(char)); 63 | lseek(f[i], 0, 0); 64 | read(f[i], a, size[i]*sizeof(char)); 65 | token = mystrtok_multi(a, s, i); 66 | while( token != NULL ) { 67 | if((mystrstr(token, argv[2]) != NULL && strcmp(argv[1], "-r") == 0) || (mystrstrcase(token, argv[2]) != NULL && strcmp(argv[1], "-ri") == 0) || (mystrstr(token, argv[2]) == NULL && strcmp(argv[1], "-rv") == 0) ) { 68 | printf("%s%s/%s%s:%s%s\n", KMAG, argv[3], dent->d_name, KBLU, KNRM, token); 69 | } 70 | token = mystrtok_multi(NULL, s, i); 71 | } 72 | close(f[i]); 73 | free (a); 74 | } 75 | i++; 76 | } 77 | closedir(dir); 78 | return 0; 79 | } 80 | } 81 | else if(strncmp(argv[1], "-m", 2) == 0) { 82 | int count[10]; 83 | int num = atoi(&argv[1][2]); 84 | for(i = 0; i < 10; i++) 85 | count[i] = 0; 86 | for(i = 1; i <= 10; i++) { 87 | f[i] = open(argv[i+2], O_RDONLY); 88 | size[i] = lseek(f[i], 0, SEEK_END); 89 | } 90 | for(i = 1; i <= 10; i++) { 91 | a = (char*)malloc(size[i]*sizeof(char)); 92 | lseek(f[i], 0, 0); 93 | read(f[i], a, size[i]*sizeof(char)); 94 | token = mystrtok_multi(a, s, i); 95 | while( token != NULL ) { 96 | if(mystrstr( token, argv[2]) != NULL) { 97 | if(argc < 5) 98 | printf("%s\n", token); 99 | else 100 | printf("%s%s : %s%s\n", KMAG, argv[i+2], KNRM, token); 101 | 102 | count[i-1]++; 103 | if(count[i-1] == num) 104 | break; 105 | } 106 | token = mystrtok_multi(NULL, s, i); 107 | } 108 | close(f[i]); 109 | free (a); 110 | } 111 | return 0; 112 | 113 | } 114 | else if(strncmp(argv[1], "-A", 2) == 0) { 115 | int num = atoi(&argv[1][2]); 116 | int j = 0; 117 | for(i = 1; i <= 10; i++) { 118 | f[i] = open(argv[i+2], O_RDONLY); 119 | size[i] = lseek(f[i], 0, SEEK_END); 120 | } 121 | for(i = 1; i <= 10; i++) { 122 | a = (char*)malloc(size[i]*sizeof(char)); 123 | lseek(f[i], 0, 0); 124 | read(f[i], a, size[i]*sizeof(char)); 125 | token = mystrtok_multi(a, s, i); 126 | while( token != NULL ) { 127 | if(mystrstr( token, argv[2]) != NULL) { 128 | if(argc < 5) 129 | printf("%s\n", token); 130 | else 131 | printf("%s%s : %s%s\n", KMAG, argv[i+2], KNRM, token); 132 | for(j = 0; j <= num; j++) { 133 | token = mystrtok_multi(NULL, s, i); 134 | if(token == NULL) 135 | break; 136 | if(mystrstr( token, argv[2]) != NULL) 137 | j = 0; 138 | if(argc < 5) 139 | printf("%s\n", token); 140 | else 141 | printf("%s%s : %s%s\n", KMAG, argv[i+2], KNRM, token); 142 | } 143 | 144 | } 145 | token = mystrtok_multi(NULL, s, i); 146 | } 147 | close(f[i]); 148 | free (a); 149 | } 150 | return 0; 151 | 152 | } 153 | 154 | else if(strcmp(argv[1], "-w") == 0) { 155 | char *p; 156 | for(i = 1; i <= 10; i++) { 157 | f[i] = open(argv[i+2], O_RDONLY); 158 | size[i] = lseek(f[i], 0, SEEK_END); 159 | } 160 | for(i = 1; i <= 10; i++) { 161 | a = (char*)malloc(size[i]*sizeof(char)); 162 | lseek(f[i], 0, 0); 163 | read(f[i], a, size[i]*sizeof(char)); 164 | token = mystrtok_multi(a, s, i); 165 | while( token != NULL ) { 166 | if(p = mystrstr(token, argv[2])) { 167 | if(isalpha(*(p - 1)) == 0 && isalpha(*(p + strlen(argv[2]))) == 0) { 168 | if(argc < 5) 169 | printf("%s\n", token); 170 | else 171 | printf("%s%s : %s%s\n", KMAG, argv[i+2], KNRM, token); 172 | } 173 | } 174 | token = mystrtok_multi(NULL, s, i); 175 | } 176 | close(f[i]); 177 | free (a); 178 | } 179 | return 0; 180 | 181 | } 182 | else if(strcmp(argv[1], "-l") == 0 || strcmp(argv[1], "-L") == 0 || strcmp(argv[1], "-il") == 0 || strcmp(argv[1], "-li") == 0 || strcmp(argv[1], "-iL") == 0 || strcmp(argv[1], "-Li") == 0) { 183 | for(i = 1; i <= 10; i++) { 184 | f[i] = open(argv[i+2], O_RDONLY); 185 | size[i] = lseek(f[i], 0, SEEK_END); 186 | } 187 | for(i = 1; i <= 10; i++) { 188 | int FLAG = 0; 189 | a = (char*)malloc(size[i]*sizeof(char)); 190 | lseek(f[i], 0, 0); 191 | read(f[i], a, size[i]*sizeof(char)); 192 | token = mystrtok_multi(a, s, i); 193 | if(strcmp(argv[1], "-Li") == 0 || strcmp(argv[1], "-iL") == 0 || strcmp(argv[1], "-li") == 0 || strcmp(argv[1], "-il") == 0) { 194 | while( token != NULL ) { 195 | if(mystrstrcase( token, argv[2]) != NULL) { 196 | FLAG = 1; 197 | break; 198 | } 199 | token = mystrtok_multi(NULL, s, i); 200 | } 201 | if(FLAG == 1 && (strcmp(argv[1], "-li") == 0 || strcmp(argv[1], "-il") == 0)) { 202 | printf("%s%s\n", KMAG, argv[i+2]); 203 | } 204 | if(FLAG == 0 && (strcmp(argv[1], "-Li") == 0 || strcmp(argv[1], "-iL") == 0)) { 205 | if(argv[i+2] == NULL) 206 | break; 207 | printf("%s%s\n", KMAG, argv[i+2]); 208 | } 209 | } 210 | else { 211 | while( token != NULL ) { 212 | if(mystrstr( token, argv[2]) != NULL) { 213 | FLAG = 1; 214 | break; 215 | } 216 | token = mystrtok_multi(NULL, s, i); 217 | } 218 | if(strcmp(argv[1], "-l") == 0 && FLAG == 1) { 219 | printf("%s%s\n", KMAG, argv[i+2]); 220 | } 221 | if(strcmp(argv[1], "-L") == 0 && FLAG == 0) { 222 | if(argv[i+2] == NULL) 223 | break; 224 | printf("%s%s\n", KMAG, argv[i+2]); 225 | } 226 | } 227 | close(f[i]); 228 | free (a); 229 | } 230 | return 0; 231 | 232 | } 233 | else if(strcmp(argv[1],"-v") == 0 || strcmp(argv[1],"-vn") == 0 || strcmp(argv[1],"-nv") == 0) { 234 | for(i = 1; i <= 10; i++) { 235 | f[i] = open(argv[i+2], O_RDONLY); 236 | size[i] = lseek(f[i], 0, SEEK_END); 237 | } 238 | for(i = 1; i <= 10; i++) { 239 | int line_num = 0; 240 | a = (char*)malloc(size[i]*sizeof(char)); 241 | lseek(f[i], 0, 0); 242 | read(f[i], a, size[i]*sizeof(char)); 243 | token = mystrtok_multi(a, s, i); 244 | while( token != NULL ) { 245 | line_num++; 246 | if(mystrstr( token, argv[2]) == NULL) { 247 | if(strcmp(argv[1],"-vn") == 0 || strcmp(argv[1],"-nv") == 0) { 248 | if(argc < 5) 249 | printf("%s%d%s:%s%s\n", KGRN, line_num, KBLU, KNRM, token); 250 | else 251 | printf("%s%s %s: %s%d %s: %s%s\n", KMAG, argv[i+2], KBLU, KGRN, line_num, KBLU, KNRM, token); 252 | } 253 | else { 254 | if(argc < 5) 255 | printf("%s\n", token); 256 | else 257 | printf("%s%s %s: %s%s\n", KMAG, argv[i+2], KBLU, KNRM, token); 258 | } 259 | } 260 | token = mystrtok_multi(NULL, s, i); 261 | } 262 | close(f[i]); 263 | free (a); 264 | } 265 | return 0; 266 | } 267 | else if(strcmp(argv[1],"-i") == 0 || strcmp(argv[1],"-in") == 0 || strcmp(argv[1],"-in") == 0) { 268 | for(i = 1; i <= 10; i++) { 269 | f[i] = open(argv[i+2], O_RDONLY); 270 | size[i] = lseek(f[i], 0, SEEK_END); 271 | } 272 | for(i = 1; i <= 10; i++) { 273 | int line_num = 0; 274 | a = (char*)malloc(size[i]*sizeof(char)); 275 | lseek(f[i], 0, 0); 276 | read(f[i], a, size[i]*sizeof(char)); 277 | token = mystrtok_multi(a, s, i); 278 | while( token != NULL ) { 279 | line_num++; 280 | if(mystrstrcase( token, argv[2]) != NULL) { 281 | if(strcmp(argv[1],"-in") == 0 || strcmp(argv[1],"-ni") == 0) { 282 | if(argc < 5) 283 | printf("%s%d%s:%s%s\n", KGRN, line_num, KBLU, KNRM, token); 284 | else 285 | printf("%s%s %s: %s%d %s: %s%s\n", KMAG, argv[i+2], KBLU, KGRN, line_num, KBLU, KNRM, token); 286 | } 287 | else { 288 | if(argc < 5) 289 | printf("%s\n", token); 290 | else 291 | printf("%s%s %s: %s%s\n", KMAG, argv[i+2], KBLU, KNRM, token); 292 | } 293 | } 294 | token = mystrtok_multi(NULL, s, i); 295 | } 296 | close(f[i]); 297 | free (a); 298 | } 299 | return 0; 300 | } 301 | else if(strcmp(argv[1], "-c") == 0 || strcmp(argv[1], "-cv") == 0 || strcmp(argv[1], "-vc") == 0) { 302 | int count[10]; 303 | for(i = 0; i < 10; i++) 304 | count[i] = 0; 305 | for(i = 1; i <= 10; i++) { 306 | f[i] = open(argv[i+2], O_RDONLY); 307 | size[i] = lseek(f[i], 0, SEEK_END); 308 | } 309 | for(i = 1; i <= 10; i++) { 310 | a = (char*)malloc(size[i]*sizeof(char)); 311 | lseek(f[i], 0, 0); 312 | read(f[i], a, size[i]*sizeof(char)); 313 | token = mystrtok_multi(a, s, i); 314 | while( token != NULL ) { 315 | if(strcmp(argv[1], "-c") == 0) { 316 | if(mystrstr( token, argv[2]) != NULL) { 317 | count[i-1]++; 318 | } 319 | } 320 | else { 321 | if(mystrstr( token, argv[2]) == NULL) { 322 | count[i-1]++; 323 | } 324 | } 325 | token = mystrtok_multi(NULL, s, i); 326 | } 327 | if(f[i] != -1) { 328 | if(argc < 5) 329 | printf("%d\n", count[i-1]); 330 | else 331 | printf("%s%s %s: %s%d\n", KMAG, argv[i+2], KBLU, KNRM, count[i-1]); 332 | } 333 | close(f[i]); 334 | free (a); 335 | } 336 | return 0; 337 | } 338 | else if(strcmp(argv[1], "-n") == 0) { 339 | for(i = 1; i <= 10; i++) { 340 | f[i] = open(argv[i+2], O_RDONLY); 341 | size[i] = lseek(f[i], 0, SEEK_END); 342 | } 343 | for(i = 1; i <= 10; i++) { 344 | int line_num = 0; 345 | a = (char*)malloc(size[i]*sizeof(char)); 346 | lseek(f[i], 0, 0); 347 | read(f[i], a, size[i]*sizeof(char)); 348 | token = mystrtok_multi(a, s, i); 349 | while( token != NULL ) { 350 | line_num++; 351 | if(mystrstr( token, argv[2]) != NULL) { 352 | if(argc < 5) 353 | printf("%s%d%s:%s%s\n", KGRN, line_num, KBLU, KNRM, token); 354 | else 355 | printf("%s%s %s: %s%d %s: %s%s\n", KMAG, argv[i+2], KBLU, KGRN, line_num, KBLU, KNRM, token); 356 | } 357 | token = mystrtok_multi(NULL, s, i); 358 | } 359 | close(f[i]); 360 | free (a); 361 | } 362 | return 0; 363 | } 364 | else if(strcmp(argv[1], "-b") == 0) { 365 | for(i = 1; i <= 10; i++) { 366 | f[i] = open(argv[i+2], O_RDONLY); 367 | size[i] = lseek(f[i], 0, SEEK_END); 368 | } 369 | for(i = 1; i <= 10; i++) { 370 | int bytes = 0; 371 | a = (char*)malloc(size[i]*sizeof(char)); 372 | lseek(f[i], 0, 0); 373 | read(f[i], a, size[i]*sizeof(char)); 374 | token = mystrtok_multi(a, s, i); 375 | while( token != NULL ) { 376 | if(mystrstr( token, argv[2]) != NULL) { 377 | if(argc < 5) 378 | printf("%s%d%s:%s%s\n", KGRN, bytes, KBLU, KNRM, token); 379 | else 380 | printf("%s%s %s: %s%d %s: %s%s\n", KMAG, argv[i+2], KBLU, KGRN, bytes, KBLU, KNRM, token); 381 | } 382 | bytes = bytes + strlen(token) + 1; 383 | token = mystrtok_multi(NULL, s, i); 384 | } 385 | close(f[i]); 386 | free (a); 387 | } 388 | return 0; 389 | } 390 | else if(strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "-H") == 0 ) { 391 | for(i = 1; i <= 10; i++) { 392 | f[i] = open(argv[i+2], O_RDONLY); 393 | size[i] = lseek(f[i], 0, SEEK_END); 394 | } 395 | for(i = 1; i <= 10; i++) { 396 | a = (char*)malloc(size[i]*sizeof(char)); 397 | lseek(f[i], 0, 0); 398 | read(f[i], a, size[i]*sizeof(char)); 399 | token = mystrtok_multi(a, s, i); 400 | while( token != NULL ) { 401 | if(mystrstr(token, argv[2]) != NULL) { 402 | if(strcmp(argv[1], "-h") == 0) 403 | printf("%s\n", token); 404 | else 405 | printf("%s%s : %s%s\n", KMAG, argv[i+2], KNRM, token); 406 | } 407 | token = mystrtok_multi(NULL, s, i); 408 | } 409 | close(f[i]); 410 | free (a); 411 | } 412 | return 0; 413 | 414 | } 415 | else { 416 | for(i = 1; i <= 10; i++) { 417 | f[i] = open(argv[i+1], O_RDONLY); 418 | size[i] = lseek(f[i], 0, SEEK_END); 419 | } 420 | for(i = 1; i <= 10; i++) { 421 | a = (char*)malloc(size[i]*sizeof(char)); 422 | lseek(f[i], 0, 0); 423 | read(f[i], a, size[i]*sizeof(char)); 424 | token = mystrtok_multi(a, s, i); 425 | while( token != NULL ) { 426 | if(mystrstr( token, argv[1]) != NULL) { 427 | if(argc < 4) 428 | printf("%s\n", token); 429 | else 430 | printf("%s%s : %s%s\n", KMAG, argv[i+1], KNRM, token); 431 | } 432 | token = mystrtok_multi(NULL, s, i); 433 | } 434 | close(f[i]); 435 | free (a); 436 | } 437 | return 0; 438 | } 439 | } 440 | -------------------------------------------------------------------------------- /Grep_Project/header.h: -------------------------------------------------------------------------------- 1 | #define KNRM "\x1B[0m" 2 | #define KRED "\x1B[31m" 3 | #define KGRN "\x1B[32m" 4 | #define KYEL "\x1B[33m" 5 | #define KBLU "\x1B[34m" 6 | #define KMAG "\x1B[35m" 7 | #define KCYN "\x1B[36m" 8 | #define KWHT "\x1B[37m" 9 | 10 | void standard_options(char *, char *); 11 | void standard_input(char *); 12 | void usage(); 13 | void recursive(char *, char *, int); 14 | char *mystrstr (char *, char *); 15 | char *mystrstrcase (char *, char *); 16 | char *mystrtok_multi (char *, char *, int); 17 | -------------------------------------------------------------------------------- /Grep_Project/mystrstr.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #include 5 | #include "header.h" 6 | #include 7 | char *mystrstr (char *a, char *b) { 8 | char *p = a, *q = b; 9 | while(*p != '\0' && *q != '\0') { 10 | if(*p == *q) { 11 | p++; 12 | q++; 13 | } 14 | else { 15 | if(q == b) 16 | p++; 17 | else { 18 | p = p - (q- b) + 1; 19 | q = b; 20 | } 21 | } 22 | } 23 | if(*q == '\0') 24 | return p - strlen(b); 25 | else 26 | return NULL; 27 | } 28 | -------------------------------------------------------------------------------- /Grep_Project/mystrstrcase.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #include "header.h" 5 | #include 6 | char *mystrstrcase (char *a, char *b) { 7 | char *p = a, *q = b; 8 | while(*p != '\0' && *q != '\0') { 9 | if((*p == *q) || ((*p - 'a' + 'A') == *q) || ((*p + 'a' - 'A') == *q)) { 10 | p++; 11 | q++; 12 | } 13 | else { 14 | if(q == b) 15 | p++; 16 | else { 17 | p = p - (q - b) + 1; 18 | q = b; 19 | } 20 | } 21 | } 22 | if(*q == '\0') 23 | return a; 24 | else 25 | return NULL; 26 | } 27 | -------------------------------------------------------------------------------- /Grep_Project/mystrtok_multi.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #include 5 | #include "header.h" 6 | #include 7 | char *mystrtok_multi(char *a, char *de, int x) { 8 | static char *c; 9 | static int j[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 10 | static int i[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 11 | int p = 0; 12 | if(a != NULL) { 13 | c = a; 14 | while(c[i[x]] != '\0') { 15 | if(c[i[x]] == de[0]) 16 | c[i[x]] = '\0'; 17 | i[x]++; 18 | } 19 | while(c[j[x]] == '\0') 20 | j[x]++; 21 | return &c[j[x]]; 22 | } 23 | else { 24 | while(j[x] < (i[x]-1)) { 25 | if(c[j[x]] == '\0' && c[j[x]]+1 != '\0') { 26 | j[x]++; 27 | return &c[j[x]]; 28 | } 29 | j[x]++; 30 | } 31 | c = NULL; 32 | return NULL; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Grep_Project/standard_input.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include 5 | #include "header.h" 6 | 7 | void standard_input(char *b) { 8 | char c; 9 | char *a; 10 | int i = 0; 11 | a = (char*)malloc(128*sizeof(char)); 12 | while(scanf("%c", &c) != -1) { 13 | if(c == '\n') { 14 | a[i] = '\0'; 15 | if(mystrstr(a, b) != NULL) 16 | printf("%s\n", a); 17 | free(a); 18 | a = (char*)malloc(128*sizeof(char)); 19 | i = 0; 20 | } 21 | else 22 | a[i++] = c; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Grep_Project/standard_options.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include 5 | #include 6 | #include "header.h" 7 | 8 | void standard_options(char *option, char *b) { 9 | char c; 10 | char *a; 11 | int i = 0; 12 | a = (char*)malloc(128*sizeof(char)); 13 | while(scanf("%c", &c) != -1) { 14 | if(c == '\n') { 15 | a[i] = '\0'; 16 | if(strcmp(option, "-i") == 0) { 17 | if(mystrstrcase(a, b) != NULL) 18 | printf("%s\n", a); 19 | } 20 | else if(strcmp(option, "-v") == 0) { 21 | if(mystrstr(a, b) == NULL) 22 | printf("%s\n", a); 23 | } 24 | else if(strcmp(option, "-iv") == 0 || strcmp(option, "-vi") == 0) 25 | if(mystrstrcase(a, b) == NULL) 26 | printf("%s\n", a); 27 | free(a); 28 | a = (char*)malloc(128*sizeof(char)); 29 | i = 0; 30 | } 31 | else 32 | a[i++] = c; 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /Grep_Project/test_dir/header.h: -------------------------------------------------------------------------------- 1 | #define KNRM "\x1B[0m" 2 | #define KRED "\x1B[31m" 3 | #define KGRN "\x1B[32m" 4 | #define KYEL "\x1B[33m" 5 | #define KBLU "\x1B[34m" 6 | #define KMAG "\x1B[35m" 7 | #define KCYN "\x1B[36m" 8 | #define KWHT "\x1B[37m" 9 | 10 | void standard_options(char *, char *); 11 | void standard_input(char *); 12 | void usage(); 13 | void recursive(char *, char *, int); 14 | char *mystrstr (char *, char *); 15 | char *mystrstrcase (char *, char *); 16 | char *mystrtok_multi (char *, char *, int); 17 | -------------------------------------------------------------------------------- /Grep_Project/test_dir/test/header.h: -------------------------------------------------------------------------------- 1 | #define KNRM "\x1B[0m" 2 | #define KRED "\x1B[31m" 3 | #define KGRN "\x1B[32m" 4 | #define KYEL "\x1B[33m" 5 | #define KBLU "\x1B[34m" 6 | #define KMAG "\x1B[35m" 7 | #define KCYN "\x1B[36m" 8 | #define KWHT "\x1B[37m" 9 | 10 | void standard_options(char *, char *); 11 | void standard_input(char *); 12 | void usage(); 13 | void recursive(char *, char *, int); 14 | char *mystrstr (char *, char *); 15 | char *mystrstrcase (char *, char *); 16 | char *mystrtok_multi (char *, char *, int); 17 | -------------------------------------------------------------------------------- /Grep_Project/test_dir/test/test2/header.h: -------------------------------------------------------------------------------- 1 | #define KNRM "\x1B[0m" 2 | #define KRED "\x1B[31m" 3 | #define KGRN "\x1B[32m" 4 | #define KYEL "\x1B[33m" 5 | #define KBLU "\x1B[34m" 6 | #define KMAG "\x1B[35m" 7 | #define KCYN "\x1B[36m" 8 | #define KWHT "\x1B[37m" 9 | 10 | void standard_options(char *, char *); 11 | void standard_input(char *); 12 | void usage(); 13 | void recursive(char *, char *, int); 14 | char *mystrstr (char *, char *); 15 | char *mystrstrcase (char *, char *); 16 | char *mystrtok_multi (char *, char *, int); 17 | -------------------------------------------------------------------------------- /Grep_Project/test_dir/test/test2/testfile.test: -------------------------------------------------------------------------------- 1 | Yo...aj 2 | Hee .... Aj is here 3 | He likes to ride bike 4 | he rides bike 5 | Aj is a good boy 6 | Be like aj 7 | -------------------------------------------------------------------------------- /Grep_Project/test_dir/test/testfile.test: -------------------------------------------------------------------------------- 1 | Yo...aj 2 | Hee .... Aj is here 3 | He likes to ride bike 4 | he rides bike 5 | Aj is a good boy 6 | Be like aj 7 | -------------------------------------------------------------------------------- /Grep_Project/test_dir/testfile.test: -------------------------------------------------------------------------------- 1 | Yo...aj 2 | Hee .... Aj is here 3 | He likes to ride bike 4 | he rides bike 5 | Aj is a good boy 6 | Be like aj 7 | -------------------------------------------------------------------------------- /Grep_Project/testfile.test: -------------------------------------------------------------------------------- 1 | Yo...aj 2 | Hee .... Aj is here 3 | He likes to ride bike 4 | he rides bike 5 | Aj is a good boy 6 | Be like aj 7 | -------------------------------------------------------------------------------- /Grep_Project/usage.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "header.h" 4 | #include 5 | void usage () { 6 | printf("Usage: ./project [OPTION] PATTERN [FILE]...\n Search for PATTERN in each FILE\n"); 7 | printf(" -r traverse through directories nd grep\n"); 8 | printf(" -w force PATTERN to match only whole words\n"); 9 | printf(" -m[NUM] stop after NUM matches\n"); 10 | printf(" -A[NUM] print NUM lines of trailing context\n"); 11 | printf(" -i ignore case distinctions\n"); 12 | printf(" -v select non-matching lines\n"); 13 | printf(" -n print line number with output lines\n"); 14 | printf(" -c print only a count of matching lines per FILE\n"); 15 | printf(" -b print the byte offset with output lines\n"); 16 | printf(" -l print only names of FILEs containing matches \n"); 17 | printf(" -L print only names of FILEs containing no match \n"); 18 | printf(" -h suppress the file name prefix on output\n"); 19 | printf(" -H print the file name for each match\n"); 20 | printf(" -ri traverse through directories and grep ignoring case distinctions\n"); 21 | printf(" -rv traverse through directories and select non matching lines\n"); 22 | printf(" -il/-li ignore case distinctions & print name of files contaning matches\n"); 23 | printf(" -iL/-Li ignore case distinctions & print name of files contaning no match\n"); 24 | printf(" -in/-ni ignore case distinctions & print line number with output lines\n"); 25 | printf(" -vn/-nv select non-matching lines & print line number with output lines\n"); 26 | printf(" -cv/-vc print only a count of non-matching lines per FILE\n"); 27 | printf("Standard Input : ./project PATTERN\n"); 28 | printf("Standard Input with options : ./project -i/-v/-iv PATTERN\n"); 29 | } 30 | -------------------------------------------------------------------------------- /Guess the number/guess_game.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | int num, guess; 8 | srand(time(0)); 9 | num = rand() % 100 + 1; 10 | char *name; 11 | printf("enter your name :\n"); 12 | scanf("%s", name); 13 | // printf("%d",num); 14 | 15 | printf("Guess the number between 1 to 100\n"); 16 | scanf("%d", &guess); 17 | 18 | int i; 19 | for (i = 1; guess != num; i++) 20 | { 21 | if (guess < num) 22 | { 23 | printf("Guess a larger number:\n"); 24 | scanf("%d", &guess); 25 | } 26 | else if (guess > num) 27 | { 28 | printf("Guess a smaller number:\n"); 29 | scanf("%d", &guess); 30 | } 31 | else 32 | { 33 | printf("Enter number pls:\n"); 34 | scanf("%d", &guess); 35 | } 36 | } 37 | 38 | printf("Congratulations!!!! You guessed it right %s! party!\n", name); 39 | 40 | printf("Guesses used : %d", i); 41 | // int i=1; 42 | // do 43 | // { 44 | // printf("Guess the number between 1 to 100:\n"); 45 | // scanf("%d",&guess); 46 | // if(guessnum){ 50 | // printf("Smaller number pls\n"); 51 | // } 52 | // else{ 53 | // printf("Congratulations! You guessed it in %d attempts.",i); 54 | // } 55 | // i++; 56 | // } while (guess!=num); 57 | 58 | return 0; 59 | } -------------------------------------------------------------------------------- /Guess the number/readme.md: -------------------------------------------------------------------------------- 1 | # About this project 2 | This project is a game, where user can guess the number in the range of 1 to 100 and the one, who uses least try, will win. 3 | ## Video Demo 4 | https://user-images.githubusercontent.com/96330400/194858248-3b1daf58-0817-4993-bf6a-33b02c63df0f.mp4 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Rancho2002 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Library Management/library-management-project-in-c-programming.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Library Management/library-management-project-in-c-programming.png -------------------------------------------------------------------------------- /Library Management/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | struct library 7 | { 8 | char bk_name[30]; 9 | char author[30]; 10 | int pages; 11 | float price; 12 | }; 13 | 14 | int main() 15 | { 16 | struct library l[100]; 17 | char ar_nm[30],bk_nm[30]; 18 | int i,j, keepcount; 19 | i=j=keepcount = 0; 20 | 21 | while(j!=6) 22 | { 23 | printf("\n\n1. Add book information\n2. Display book information\n"); 24 | printf("3. List all books of given author\n"); 25 | printf("4. List the title of specified book\n"); 26 | printf("5. List the count of books in the library\n"); 27 | printf("6. Exit"); 28 | 29 | printf ("\n\nEnter one of the above : "); 30 | scanf("%d",&j); 31 | 32 | switch (j) 33 | { 34 | /* Add book */ 35 | case 1: 36 | 37 | printf ("Enter book name = "); 38 | scanf ("%s",l[i].bk_name); 39 | 40 | printf ("Enter author name = "); 41 | scanf ("%s",l[i].author); 42 | 43 | printf ("Enter pages = "); 44 | scanf ("%d",&l[i].pages); 45 | 46 | printf ("Enter price = "); 47 | scanf ("%f",&l[i].price); 48 | keepcount++; 49 | 50 | break; 51 | case 2: 52 | printf("you have entered the following information\n"); 53 | for(i=0; i 2 | #include 3 | //User Defined Function Declaration 4 | void readMatrix(int array[10][10], int rows, int colums); 5 | void printMatrix(int array[10][10], int rows, int colums); 6 | void matrixAddSub(int arrayone[10][10], int arraytwo[10][10], int rows, int colums, int mul); 7 | void matrixScalarMultiply(int array[10][10], int scalar, int rows, int colums); 8 | void matrixMultiply(int arrayone[10][10], int arraytwo[10][10], int rowsA, int columsA, int columsB); 9 | int main(void){ 10 | 11 | int i, j, k; //used in for loops 12 | 13 | int matrixA[10][10]; // initialized at 10 just to have it initialized 14 | int matrixB[10][10]; 15 | int rowA, colA; 16 | int rowB, colB; 17 | int operation;//used in swtich statements 18 | char again = 'Y'; 19 | int scalar = 0; 20 | int add = 1; 21 | int sub = -1; 22 | 23 | while (again == 'Y'){ 24 | 25 | 26 | //this is the operation menu just type A, B, C or D to calculate 27 | printf("\nOperation Menu\n"); 28 | printf("\t1. to Add\n"); 29 | printf("\t2. to Subtract\n"); 30 | printf("\t3. to Scalar Multiply\n"); 31 | printf("\t4. to Multiply two matrices\n"); 32 | printf("Enter your choice: "); 33 | scanf(" %d", &operation); 34 | 35 | 36 | switch (operation){ 37 | 38 | case 1: 39 | printf("\nEnter the #rows and #cols for matrix A: "); 40 | scanf("%d%d", &rowA, &colA); 41 | 42 | printf("Enter the #rows and #cols for matrix B: "); 43 | scanf("%d%d", &rowB, &colB); 44 | 45 | while ((rowA != rowB) && (colA != colB)){ 46 | printf("\nMatrices must be the same size\n"); 47 | printf("\nEnter the #rows and #cols for matrix A: "); 48 | scanf("%d%d", &rowA, &colA); 49 | 50 | printf("Enter the #rows and #cols for matrix B: "); 51 | scanf("%d%d", &rowB, &colB); 52 | 53 | } 54 | 55 | 56 | printf("\n\tEnter elements of Matrix A a %d x %d matrix.\n", rowA, colA); // with the %d we remember the user the dimensions of the array 57 | readMatrix(matrixA, rowA, colA); 58 | printf("\n\t\tMatrix A\n\n"); 59 | printMatrix(matrixA, rowA, colA); 60 | 61 | 62 | printf("\n\tEnter elements of Matrix B a %d x %d matrix.\n", rowB, colB); // with the %d we remember the user the dimensions of the array 63 | readMatrix(matrixB, rowB, colB); 64 | printf("\n\t\tMatrix B\n\n"); 65 | printMatrix(matrixB, rowB, colB); 66 | 67 | 68 | printf("\nThe Sum of matrixA + matrixB is : \n"); 69 | matrixAddSub(matrixA, matrixB, rowA, colA, add); 70 | 71 | break; 72 | 73 | case 2: 74 | 75 | printf("\nEnter the #rows and #cols for matrix A: "); 76 | scanf("%d%d", &rowA, &colA); 77 | 78 | printf("Enter the #rows and #cols for matrix B: "); 79 | scanf("%d%d", &rowB, &colB); 80 | 81 | while ((rowA != rowB) && (colA != colB)){ 82 | printf("\nMatrices must be the same size\n"); 83 | printf("\nEnter the #rows and #cols for matrix A: "); 84 | scanf("%d%d", &rowA, &colA); 85 | 86 | printf("Enter the #rows and #cols for matrix B: "); 87 | scanf("%d%d", &rowB, &colB); 88 | } 89 | 90 | printf("\n\tEnter elements of Matrix A a %d x %d matrix.\n", rowA, colA); // with the %d we remember the user the dimensions of the array 91 | readMatrix(matrixA, rowA, colA); 92 | printf("\n\t\tMatrix A\n\n"); 93 | printMatrix(matrixA, rowA, colA); 94 | 95 | printf("\n\tEnter elements of Matrix B a %d x %d matrix.\n", rowB, colB); // with the %d we remember the user the dimensions of the array 96 | readMatrix(matrixB, rowB, colB); 97 | printf("\n\t\tMatrix B\n\n"); 98 | printMatrix(matrixB, rowB, colB); 99 | 100 | printf("\nThe difference between matrixA - matrixB is : \n"); 101 | matrixAddSub(matrixA, matrixB, rowA, colA, sub); 102 | break; 103 | 104 | case 3: 105 | 106 | printf("\nEnter the scalar: "); 107 | scanf("%d", &scalar); 108 | printf("\nThe scalar is: %d ", scalar); 109 | 110 | 111 | printf("\nEnter the #rows and #cols for matrix A: "); 112 | scanf("%d%d", &rowA, &colA); 113 | 114 | printf("\n\tEnter elements of Matrix A a %d x %d matrix.\n", rowA, colA); // with the %d we remember the user the dimensions of the array 115 | readMatrix(matrixA, rowA, colA); 116 | printf("\n\t\tMatrix A\n\n"); 117 | printMatrix(matrixA, rowA, colA); 118 | 119 | printf("\nThe scalar multiplication between matrixA * %d is: \n", scalar); 120 | matrixScalarMultiply(matrixA, scalar, rowA, colA); 121 | 122 | break; 123 | 124 | case 4: 125 | //when multiplying arrays matrixA column # has to equal matrixB row # 126 | printf("\nEnter the #rows and #cols for matrix A: "); 127 | scanf("%d%d", &rowA, &colA); 128 | 129 | printf("Enter the #rows and #cols for matrix B: "); 130 | scanf("%d%d", &rowB, &colB); 131 | 132 | // Column of first matrix should be equal to column of second matrix and 133 | while (colA != rowB) 134 | { 135 | printf("\n\nError! column of first matrix not equal to row of second.\n\n"); 136 | printf("\nEnter the #rows and #cols for matrix A: "); 137 | scanf("%d%d", &rowA, &colA); 138 | 139 | printf("Enter the #rows and #cols for matrix B: "); 140 | scanf("%d%d", &rowB, &colB); 141 | } 142 | 143 | // Storing elements of first matrix. 144 | printf("\n\tEnter elements of Matrix A a %d x %d matrix.\n", rowA, colA); // with the %d we remember the user the dimensions of the array 145 | readMatrix(matrixA, rowA, colA); 146 | printf("\n\t\tMatrix A\n\n"); 147 | printMatrix(matrixA, rowA, colA); 148 | 149 | // Storing elements of second matrix. 150 | printf("\n\tEnter elements of Matrix B a %d x %d matrix.\n", rowB, colB); // with the %d we remember the user the dimensions of the array 151 | readMatrix(matrixB, rowB, colB); 152 | printf("\n\t\tMatrix A\n\n"); 153 | printMatrix(matrixB, rowB, colB); 154 | 155 | //multiplyng arrays 156 | matrixMultiply(matrixA, matrixB, rowA, colA, colB); 157 | 158 | break; 159 | 160 | default: 161 | printf("\nIncorrect option! Please choose a number 1-4."); 162 | break; 163 | } 164 | 165 | printf("\n\nDo you want to calculate again? Y/N\n"); 166 | scanf(" %c", &again); 167 | again = toupper(again); 168 | } 169 | printf("\n\nGoodbye!\n\n"); 170 | 171 | return 0; 172 | } 173 | 174 | 175 | //User Defined Function Definition 176 | void readMatrix(int array[10][10], int rows, int colums){ 177 | int i, j; 178 | for (i = 0; i < rows; i++){ 179 | printf("\t%d entries for row %d: ", colums, i + 1); 180 | for (j = 0; j < colums; j++){ 181 | scanf("%d", &array[i][j]); 182 | } 183 | } 184 | 185 | return; 186 | } 187 | 188 | void printMatrix(int array[10][10], int rows, int colums){ 189 | int i, j; 190 | 191 | for (i = 0; i < rows; i++) { 192 | for (j = 0; j < colums; j++){ 193 | printf("\t%d", array[i][j]); 194 | } 195 | printf("\n"); 196 | } 197 | } 198 | 199 | 200 | void matrixAddSub(int arrayone[10][10], int arraytwo[10][10], int rows, int colums, int mul){ 201 | int i, j; 202 | int sumM[10][10]; 203 | int scaM[10][10]; 204 | for (i = 0; i < rows; i++){ 205 | for (j = 0; j < colums; j++){ 206 | scaM[i][j] = mul * arraytwo[i][j]; 207 | } 208 | } 209 | 210 | 211 | for (i = 0; i < rows; i++){ 212 | for (j = 0; j < colums; j++){ 213 | sumM[i][j] = arrayone[i][j] + scaM[i][j]; 214 | printf("\t%d", sumM[i][j]); 215 | } 216 | printf("\n"); 217 | } 218 | } 219 | 220 | 221 | void matrixScalarMultiply(int array[10][10], int scalar, int rows, int colums){ 222 | int i, j; 223 | int scaM[10][10]; 224 | for (i = 0; i < rows; i++){ 225 | for (j = 0; j < colums; j++){ 226 | scaM[i][j] = scalar * array[i][j]; 227 | printf("%d\t", scaM[i][j]); 228 | } 229 | printf("\n"); 230 | } 231 | 232 | } 233 | 234 | void matrixMultiply(int arrayone[10][10], int arraytwo[10][10], int rowsA, int columsA,int columsB){ 235 | int i, j, k; 236 | int mulM[10][10]; 237 | 238 | // Initializing all elements of result matrix to 0 239 | for (i = 0; i 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | 9 | 10 | 11 | struct currentValidID{ 12 | 13 | int year; 14 | 15 | char branch[6]; 16 | 17 | int totalVoters; 18 | 19 | }; 20 | 21 | typedef struct candidate{ 22 | 23 | int cid; 24 | 25 | char cname[20]; 26 | 27 | int votes; 28 | 29 | }CANDIDATE; 30 | 31 | 32 | 33 | //GLOBALS -------------------------------------------------------- 34 | 35 | struct currentValidID currentValidID; //stores current Valid user ID parameters 36 | 37 | CANDIDATE candidateArray[20]; //to store information all candidates 38 | 39 | int numberOfCandidates; //Total number of candidates standing for election 40 | 41 | char studentVotes[200]; //to store information of votes given by each student 42 | 43 | //---------------------------------------------------------------- 44 | 45 | 46 | 47 | //To extract year from userID -- For example, userID:2018btecs00064 year:2018 48 | 49 | int extractYear(char userID[15]) 50 | 51 | { 52 | 53 | int year=0; 54 | 55 | char tmp; 56 | 57 | for(int i=0;i<4;i++){ 58 | 59 | tmp=userID[i]; 60 | 61 | year=(year*10)+(tmp-48); 62 | } 63 | 64 | return year; 65 | 66 | } 67 | 68 | 69 | 70 | int extractRollNo(char userID[15]) 71 | 72 | { 73 | 74 | int rollno=0; 75 | 76 | char tmp; 77 | 78 | for(int i=9;i<14;i++){ 79 | 80 | tmp=userID[i]; 81 | 82 | rollno=(rollno*10)+(tmp-48); 83 | 84 | } 85 | 86 | return rollno; 87 | 88 | } 89 | 90 | 91 | 92 | //Will check whether the global branch code and inputed branch code is matching or not 93 | 94 | int checkBranchCode(char userID[15]) 95 | 96 | { 97 | 98 | char branchCode[6]; 99 | 100 | for(int i=4;i<9;i++){ 101 | 102 | branchCode[i-4]=userID[i]; 103 | 104 | } 105 | 106 | branchCode[5]='\0'; 107 | 108 | if(strcmp(branchCode,currentValidID.branch)==0) 109 | 110 | return 1; 111 | 112 | else 113 | 114 | return 0; 115 | 116 | } 117 | 118 | 119 | 120 | int authenticateAdmin(){ 121 | 122 | char username[15], password[6]; 123 | 124 | 125 | 126 | printf("\nEnter username: "); 127 | 128 | scanf("%s",username); 129 | 130 | if((strcmp(username,"Admin"))!=0) 131 | 132 | return 0; 133 | 134 | else 135 | 136 | { 137 | 138 | printf("Enter Password: "); 139 | 140 | int i=0; 141 | 142 | for(i=0;i<5;i++) 143 | 144 | { 145 | 146 | password[i]=getch(); 147 | 148 | printf("%c",'*'); 149 | 150 | } 151 | 152 | password[i]='\0'; 153 | 154 | if((strcmp(password,"admiN"))!=0) 155 | 156 | return 0; 157 | 158 | } 159 | 160 | return 1; 161 | 162 | } 163 | 164 | 165 | 166 | void banID(){ 167 | 168 | printf("\nCreating Banned.txt...\n"); 169 | 170 | FILE *fp=fopen("Banned.txt", "w"); 171 | 172 | if(fp==NULL){ 173 | 174 | printf("Error: Banned.txt not created.\n"); 175 | 176 | fclose(fp); 177 | 178 | return; 179 | 180 | } 181 | 182 | printf("Just Enter last roll no to ban\nPress 0 to exit... "); 183 | 184 | int input; 185 | 186 | while(1){ 187 | 188 | printf("\nEnter Number: "); 189 | 190 | scanf("%d",&input); 191 | 192 | if(input==0) 193 | 194 | break; 195 | 196 | studentVotes[input-1]='$'; 197 | 198 | fprintf(fp,"%d\n",input); 199 | 200 | } 201 | 202 | fclose(fp); 203 | 204 | printf("Created Successfully\n"); 205 | 206 | } 207 | 208 | 209 | 210 | void createCandidateFiles(){ 211 | 212 | printf("\nCreating candidate files...\n"); 213 | 214 | FILE *fp; 215 | 216 | char filename[20]; 217 | 218 | for(int i = 1;i <= numberOfCandidates; i++){ 219 | 220 | sprintf(filename,"candidate%d.txt",i); 221 | 222 | fp=fopen(filename,"w"); 223 | 224 | fprintf( 225 | 226 | fp,"0\n%s", 227 | 228 | candidateArray[i-1].cname 229 | 230 | ); 231 | 232 | fclose(fp); 233 | 234 | } 235 | 236 | printf("Created Files successfully\n"); 237 | 238 | } 239 | 240 | 241 | 242 | void deleteIllegalVote(char userID[15]) 243 | 244 | { 245 | 246 | FILE *fp,*fcp; 247 | 248 | char filename[20]; 249 | 250 | char line[20]; 251 | 252 | 253 | 254 | int location = extractRollNo(userID); 255 | 256 | sprintf(filename,"candidate%d.txt",candidateArray[studentVotes[location-1]-49].cid); 257 | 258 | candidateArray[studentVotes[location-1]-49].votes--; 259 | 260 | studentVotes[location-1]='0'; 261 | 262 | if ((fp = fopen(filename,"r")) == NULL) 263 | 264 | { 265 | 266 | printf("\nFile cannot be opened...Operation Failed"); 267 | 268 | return; 269 | 270 | } 271 | 272 | printf("\nDeleting in process...\n "); 273 | 274 | if ((fcp = fopen("tmp.txt","w")) == NULL) 275 | 276 | { 277 | 278 | printf("\nFile cannot be opened...Operation Failed"); 279 | 280 | return; 281 | 282 | } 283 | 284 | 285 | 286 | while (!feof(fp)) 287 | 288 | { 289 | 290 | fscanf(fp,"%s",line); 291 | 292 | fprintf(fcp,"%s\n",line); 293 | 294 | } 295 | 296 | fclose(fp); 297 | 298 | fclose(fcp); 299 | 300 | if ((fp = fopen(filename,"w")) == NULL) 301 | 302 | { 303 | 304 | printf("\nFile cannot be opened...Operation Failed"); 305 | 306 | return; 307 | 308 | } 309 | 310 | int numFromFile; 311 | 312 | char cnameFromFile[20]; 313 | 314 | fcp = fopen("tmp.txt","r"); 315 | 316 | fscanf(fcp,"%d",&numFromFile); 317 | 318 | fprintf(fp,"%d",numFromFile-1); 319 | 320 | fscanf(fcp,"%s",cnameFromFile); 321 | 322 | fprintf(fp,"\n%s",cnameFromFile); 323 | 324 | while(!feof(fcp)){ 325 | 326 | fscanf(fcp,"%d",&numFromFile); 327 | 328 | if(numFromFile!=location) 329 | 330 | fprintf(fp,"\n%d",numFromFile); 331 | 332 | } 333 | 334 | fclose(fp); 335 | 336 | fclose(fcp); 337 | 338 | remove("tmp.txt"); 339 | 340 | printf("\nVote deleted successfully\nPress any key to continue..."); 341 | 342 | getch(); 343 | 344 | } 345 | 346 | 347 | 348 | int getWinner(){ 349 | 350 | int maxV = -1; 351 | 352 | int winnerCid; 353 | 354 | for(int i = 0;i < numberOfCandidates; i++){ 355 | 356 | if(candidateArray[i].votes > maxV) { 357 | 358 | winnerCid = candidateArray[i].cid; 359 | 360 | maxV = candidateArray[i].votes; 361 | 362 | } 363 | 364 | else if(candidateArray[i].votes == maxV) { 365 | 366 | return -1; 367 | 368 | } 369 | 370 | } 371 | 372 | return winnerCid; 373 | 374 | } 375 | 376 | 377 | 378 | void initiateNewElection() 379 | 380 | { 381 | 382 | printf("\nNew Election Initiation:\n"); 383 | 384 | 385 | 386 | printf("\nElections for which Year: "); 387 | 388 | scanf("%d",¤tValidID.year); 389 | 390 | printf("Enter branch code:"); 391 | 392 | scanf("%s",currentValidID.branch); 393 | 394 | printf("Enter max roll no.:"); 395 | 396 | scanf("%d",¤tValidID.totalVoters); 397 | 398 | printf("Enter the no. of candidates:"); 399 | 400 | scanf("%d",&numberOfCandidates); 401 | 402 | 403 | 404 | for (int i = 0; i < currentValidID.totalVoters; i++) 405 | 406 | { 407 | 408 | studentVotes[i] = '0'; 409 | 410 | } 411 | 412 | 413 | 414 | for (int i = 0;i < numberOfCandidates; i++) 415 | 416 | { 417 | 418 | candidateArray[i].cid=i+1; 419 | 420 | printf("Enter name of candidate %d: ",i+1); 421 | 422 | scanf(" %s",candidateArray[i].cname); 423 | 424 | candidateArray[i].votes=0; 425 | 426 | } 427 | 428 | return; 429 | 430 | } 431 | 432 | 433 | 434 | void saveElectionInfoInFile(){ 435 | 436 | printf("Saving Election Info in File...\n"); 437 | 438 | FILE *fp = fopen("ElectionInfo.txt", "w"); 439 | 440 | if(fp==NULL) 441 | 442 | { 443 | 444 | printf("\nError in file creation\n"); 445 | 446 | fclose(fp); 447 | 448 | return; 449 | 450 | } 451 | 452 | fprintf( 453 | 454 | fp,"%d\n%s\n%d\n%d", 455 | 456 | currentValidID.year, 457 | 458 | currentValidID.branch, 459 | 460 | currentValidID.totalVoters, 461 | 462 | numberOfCandidates 463 | 464 | ); 465 | 466 | fclose(fp); 467 | 468 | printf("Saved Successfully : )"); 469 | 470 | } 471 | 472 | 473 | 474 | void loadElectionInfoFromFile() 475 | 476 | { 477 | 478 | FILE *f1,*f2,*f3; 479 | 480 | f1=fopen("ElectionInfo.txt","r"); 481 | 482 | if(f1==NULL) 483 | 484 | printf("Not Exist"); 485 | 486 | fscanf(f1,"%d",¤tValidID.year); 487 | 488 | fseek(f1,2,SEEK_CUR); 489 | 490 | fscanf(f1,"%s",currentValidID.branch); 491 | 492 | fseek(f1,2,SEEK_CUR); 493 | 494 | fscanf(f1,"%d",¤tValidID.totalVoters); 495 | 496 | fseek(f1,2,SEEK_CUR); 497 | 498 | fscanf(f1,"%d",&numberOfCandidates); 499 | 500 | fclose(f1); 501 | 502 | 503 | 504 | //load candidates info and student votes 505 | 506 | for (int i = 0; i < currentValidID.totalVoters; i++) 507 | 508 | { 509 | 510 | studentVotes[i] = '0'; 511 | 512 | } 513 | 514 | for(int i=1;i<=numberOfCandidates;i++) 515 | 516 | { 517 | 518 | int location; 519 | 520 | char filename[20]; 521 | 522 | sprintf(filename,"candidate%d.txt",i); 523 | 524 | f2=fopen(filename,"r+"); 525 | 526 | candidateArray[i-1].cid=i; 527 | 528 | fscanf(f2,"%d",&candidateArray[i-1].votes); 529 | 530 | fscanf(f2,"%s",candidateArray[i-1].cname); 531 | 532 | while(!feof(f2)){ 533 | 534 | fscanf(f2,"%d",&location); 535 | 536 | studentVotes[location-1] = i+48; 537 | 538 | } 539 | 540 | fclose(f2); 541 | 542 | } 543 | 544 | 545 | 546 | //load banned votes 547 | 548 | int location; 549 | 550 | f3=fopen("banned.txt","r+"); 551 | 552 | while(!feof(f3)){ 553 | 554 | fscanf(f3,"%d",&location); 555 | 556 | studentVotes[location-1] = '$'; 557 | 558 | } 559 | 560 | fclose(f3); 561 | 562 | 563 | 564 | } 565 | 566 | 567 | 568 | void adminPanel() 569 | 570 | { 571 | 572 | while(1){ 573 | 574 | 575 | 576 | if(authenticateAdmin()!=1){ 577 | 578 | printf("\n Wrong Username or Password \n"); 579 | 580 | break; 581 | 582 | } 583 | 584 | 585 | 586 | printf("\n\nLOGGED IN SUCCESSFULLY (Press Enter)"); 587 | 588 | getch(); 589 | 590 | 591 | 592 | while(1) 593 | 594 | { 595 | 596 | char inputID[15]; 597 | 598 | char input;char banInp; 599 | 600 | int WinnerCid, totalVotedNow=0; 601 | 602 | printf("\n1.New Election\n2.Continue Previous Election\n3.Delete Illegal Vote\n4.Ban User IDs\n5.Result\n6.Logout\nOption:"); 603 | 604 | scanf(" %c",&input); 605 | 606 | 607 | 608 | switch(input) 609 | 610 | { 611 | 612 | case '1': 613 | 614 | initiateNewElection(); 615 | 616 | saveElectionInfoInFile(); 617 | 618 | createCandidateFiles(); 619 | 620 | break; 621 | 622 | case '2': 623 | 624 | loadElectionInfoFromFile(); 625 | 626 | break; 627 | 628 | case '3': 629 | 630 | printf("\nEnter user ID to delete its vote: "); 631 | 632 | scanf("%s",inputID); 633 | 634 | deleteIllegalVote(inputID); 635 | 636 | break; 637 | 638 | case '4': 639 | 640 | printf("Do you want to ban particular ID's?\nPress 1 if yes or any other key to continue..."); 641 | 642 | scanf(" %c",&banInp); 643 | 644 | if(banInp=='1'){ 645 | 646 | banID(); 647 | 648 | } 649 | 650 | break; 651 | 652 | case '5': 653 | 654 | WinnerCid = getWinner(); 655 | 656 | if(WinnerCid != -1){ 657 | 658 | printf("\nWinner is %s with %d votes\n",candidateArray[WinnerCid-1].cname,candidateArray[WinnerCid-1].votes); 659 | 660 | } 661 | 662 | else{ 663 | 664 | printf("\nIts A TIE"); 665 | 666 | } 667 | 668 | printf("\nFull Result\n"); 669 | 670 | for(int i=0;i %d votes\n",candidateArray[i].cid,candidateArray[i].cname,candidateArray[i].votes); 675 | 676 | } 677 | 678 | printf("\nVoting Percentage: %d %%\n\n",(totalVotedNow*100)/currentValidID.totalVoters); 679 | 680 | break; 681 | 682 | case '6': 683 | 684 | return; 685 | 686 | default: 687 | 688 | printf("Invalid Option"); 689 | 690 | getch(); 691 | 692 | } 693 | 694 | 695 | 696 | } 697 | 698 | } 699 | 700 | 701 | 702 | }; 703 | 704 | 705 | 706 | 707 | 708 | int isValid(char userID[15]) 709 | 710 | { 711 | 712 | if(strlen(userID)!=14) 713 | 714 | return 0; 715 | 716 | 717 | 718 | int inputedYear=extractYear(userID); 719 | 720 | int inputedRollNo = extractRollNo(userID); 721 | 722 | 723 | 724 | if(inputedYear!=currentValidID.year || checkBranchCode(userID)!=1 || inputedRollNo>currentValidID.totalVoters) 725 | 726 | return 0; 727 | 728 | 729 | 730 | return 1; 731 | 732 | } 733 | 734 | 735 | 736 | int isVoted(char userID[15]) 737 | 738 | { 739 | 740 | int location=extractRollNo(userID); 741 | 742 | if(studentVotes[location-1]=='0') 743 | 744 | return 0; 745 | 746 | else 747 | 748 | return 1; 749 | 750 | } 751 | 752 | 753 | 754 | int isBanned(char userID[15]){ 755 | 756 | int location=extractRollNo(userID); 757 | 758 | if(studentVotes[location-1]=='$') 759 | 760 | return 1; 761 | 762 | else 763 | 764 | return 0; 765 | 766 | } 767 | 768 | 769 | 770 | void saveVote(char userID[15],char voteInput) 771 | 772 | { 773 | 774 | char filename[20]; 775 | 776 | sprintf(filename,"candidate%d.txt",voteInput-48); 777 | 778 | FILE *fp = fopen(filename,"r+"); 779 | 780 | int location=extractRollNo(userID); 781 | 782 | studentVotes[location-1]=voteInput; 783 | 784 | candidateArray[voteInput-49].votes++; 785 | 786 | fseek(fp, 0, SEEK_SET); 787 | 788 | fprintf(fp,"%d\n",candidateArray[voteInput-49].votes); 789 | 790 | fseek(fp, 0, SEEK_END); 791 | 792 | fprintf(fp,"\n%d",location); 793 | 794 | fclose(fp); 795 | 796 | } 797 | 798 | 799 | 800 | 801 | 802 | void studentPanel() 803 | 804 | { 805 | 806 | char userID[15]; 807 | 808 | char voteInput; 809 | 810 | while(1) 811 | 812 | { 813 | 814 | printf("\n\n To exit press 0"); 815 | 816 | printf("\n Enter user ID:"); 817 | 818 | scanf("%s",userID); 819 | 820 | if(strcmp(userID, "0")==0) 821 | 822 | return; 823 | 824 | if(isValid(userID)!=1) 825 | 826 | { 827 | 828 | printf("\n Invalid User ID(Press Enter)"); 829 | 830 | getch(); 831 | 832 | continue; 833 | 834 | } 835 | 836 | if(isBanned(userID)!=0) 837 | 838 | { 839 | 840 | printf("\nThis User ID is currently banned...\nContact Admin for the reason...(Press Enter to continue)"); 841 | 842 | getch(); 843 | 844 | continue; 845 | 846 | } 847 | 848 | if(isVoted(userID)!=0) 849 | 850 | { 851 | 852 | printf("\n Your PRN entered is already voted\n Contact Admin for furthur query"); 853 | 854 | getch(); 855 | 856 | continue; 857 | 858 | } 859 | 860 | printf("\n\n Candidates for election:"); 861 | 862 | for (int i = 0; i < numberOfCandidates; i++) 863 | 864 | { 865 | 866 | printf("\n %d. %s",i+1,candidateArray[i].cname); 867 | 868 | } 869 | 870 | printf("\n\n Your Vote(Enter Number):"); 871 | 872 | voteInput=getch(); 873 | 874 | printf("*"); 875 | 876 | if(voteInput-48 < 1 || voteInput-48 > numberOfCandidates) 877 | 878 | { 879 | 880 | printf("\nInvalid Vote\nTry Again..."); 881 | 882 | getch(); 883 | 884 | continue; 885 | 886 | } 887 | 888 | saveVote(userID,voteInput); 889 | 890 | printf("\n\nThanks for your precious vote(Press Enter)"); 891 | 892 | getch(); 893 | 894 | } 895 | 896 | }; 897 | -------------------------------------------------------------------------------- /Mini-Voting-System/Main.c: -------------------------------------------------------------------------------- 1 | #include"election.h" 2 | 3 | 4 | 5 | int main(){ 6 | 7 | while(1){ 8 | 9 | printf("\n\t\t\t 1.Student panel \n\t\t\t 2.Admin panel \n\t\t\t 3.Exit \n\t\t\t Option:"); 10 | 11 | char input; 12 | scanf(" %c",&input); 13 | 14 | 15 | 16 | switch(input){ 17 | 18 | case '1': 19 | 20 | studentPanel(); 21 | 22 | break; 23 | 24 | case '2': 25 | 26 | adminPanel(); 27 | 28 | break; 29 | 30 | case '3': 31 | 32 | return 0; 33 | 34 | default: 35 | 36 | printf("\nInvalid option"); 37 | 38 | getch(); 39 | 40 | } 41 | 42 | } 43 | 44 | return 0; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Mini-Voting-System/readme.md: -------------------------------------------------------------------------------- 1 | Mini-Voting-System-Using-C-Language 2 | 3 | -> Allows us to set up a flexible and trustworthy voting system 4 | 5 | -> Applicable for large as well as small group of people e.g. a batch, a class. 6 | 7 | -> Keeps a record of every voting process. 8 | 9 | How to use? 10 | 11 | You can fork or download the repo, Once you have both the files "MAIN.C" and "ELECTION.H", You just need to compile and run MAIN.C 12 | 13 | ( It's too easy, isn't it? relaxed) 14 | 15 | For Admin Panel Use Username: "Admin" Password: "admiN" 16 | 17 | Below is the video to see demo of project 18 | 19 | Link: https://drive.google.com/file/d/17yFA8VC9chpWav8kXXIYQR4B55sf4W9b/view?usp=sharing 20 | 21 | Feel free to raise issues if you find some errors or want to clear your doubts... 22 | 23 | #mini project #voting system #c project 24 | -------------------------------------------------------------------------------- /Musicplayer/README.md: -------------------------------------------------------------------------------- 1 | This projects in C lets you create a playlist of songs 2 | You can use the following options: 3 | 1. Create a new song 4 | 2. Display all available songs 5 | 3. Create a new playlist 6 | 4. Add a song to the playlist 7 | 5. Show playlist 8 | 6. Play previous track 9 | 7. Play next track 10 | 8. Exit music player
11 | # You can check the preview here
12 | https://user-images.githubusercontent.com/49357847/197374401-b69f7fee-5c43-4669-ba7c-815071303327.mp4 13 | 14 | -------------------------------------------------------------------------------- /Musicplayer/music_player.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #ifdef _WIN32 8 | #include 9 | #else 10 | #include 11 | #endif 12 | 13 | #define MAX_SONG_POOL 120 14 | #define MAX_STRING_SIZE 75 15 | 16 | // Data Structure for an individual song 17 | 18 | typedef struct Song *songptr; 19 | typedef struct Song 20 | { 21 | char title[MAX_STRING_SIZE]; 22 | char album[MAX_STRING_SIZE]; 23 | char uri[MAX_STRING_SIZE]; 24 | char id[MAX_STRING_SIZE]; 25 | short int year; 26 | double duration; 27 | } Song; 28 | 29 | songptr song_pool[MAX_SONG_POOL]; 30 | int pool_insert_index = 0; 31 | 32 | typedef struct PlaylistNode *node_ptr; 33 | typedef struct PlaylistNode 34 | { 35 | songptr song; 36 | node_ptr prev_song; 37 | node_ptr next_song; 38 | } PlaylistNode; 39 | 40 | node_ptr header_node = NULL, now_playing = NULL; 41 | 42 | //Function to check if the song pool is empty 43 | bool is_pool_empty() 44 | { 45 | return song_pool[0] == NULL; 46 | } 47 | 48 | //Function to check if playlist exists 49 | bool does_playlist_exist() 50 | { 51 | return !(header_node == NULL); 52 | } 53 | 54 | void play_next_song() 55 | { 56 | if (does_playlist_exist() && now_playing != NULL) 57 | { 58 | if (now_playing->next_song != NULL) 59 | now_playing = now_playing->next_song; 60 | else 61 | printf("REACHED END OF PLAYLIST"); 62 | } 63 | else 64 | { 65 | printf("NO SONG ADDED TO PLAYLIST"); 66 | } 67 | } 68 | 69 | void play_prev_song() 70 | { 71 | if (does_playlist_exist() && now_playing != NULL) 72 | { 73 | if (now_playing->prev_song != NULL) 74 | now_playing = now_playing->prev_song; 75 | else 76 | printf("REACHED START OF PLAYLIST"); 77 | } 78 | else 79 | { 80 | printf("NO SONG ADDED TO PLAYLIST"); 81 | } 82 | } 83 | 84 | void show_song_details() 85 | { 86 | if (now_playing == NULL || now_playing->song == NULL) 87 | { 88 | printf(" CREATE A PLAYLIST FIRST\n"); 89 | } 90 | else 91 | { 92 | printf("\n----------------------------------------------------------------------\n"); 93 | printf(" DETAILED OVERVIEW\n"); 94 | printf("----------------------------------------------------------------------\n"); 95 | printf("\t TITLE | %s\n", now_playing->song->title); 96 | printf("\t ALBUM | %s\n", now_playing->song->album); 97 | printf("\t YEAR | %d\n", now_playing->song->year); 98 | printf("\t DURATION | %0.2lf minutes\n", now_playing->song->duration); 99 | printf("\tSPOTIFY URI | %s\n", now_playing->song->uri); 100 | printf(" Paste the above URI in your browser to play the song on Spotify\n"); 101 | printf("----------------------------------------------------------------------\n"); 102 | } 103 | char leave[MAX_STRING_SIZE]; 104 | printf("<<<<< Enter any input to return to MAIN MENU\n"); 105 | if (scanf("%s", leave)) 106 | { 107 | system("clear"); 108 | return; 109 | } 110 | } 111 | 112 | void main_menu() 113 | { 114 | printf("\n----------------------------------------------------------------------\n"); 115 | printf(" MAIN MENU\n"); 116 | printf("----------------------------------------------------------------------\n"); 117 | 118 | if (now_playing == NULL || now_playing->song == NULL) 119 | { 120 | printf(" NO TRACK SELECTED\n"); 121 | } 122 | else 123 | { 124 | printf(" NOW | %s\n", now_playing->song->title); 125 | printf(" PLAYING | %0.2lf minutes\n", now_playing->song->duration); 126 | } 127 | printf("----------------------------------------------------------------------\n"); 128 | printf(" # | Action \n"); 129 | printf("----------------------------------------------------------------------\n"); 130 | printf(" 1 | Create a new song\n"); 131 | printf(" 2 | Display all available songs\n"); 132 | if (does_playlist_exist()) 133 | printf(" 3 | Delete playlist\n"); 134 | else 135 | printf(" 3 | Create a new playlist\n"); 136 | printf(" 4 | Add a song to the playlist\n"); 137 | printf(" 5 | Show playlist\n"); 138 | printf(" 6 | Play previous track\n"); 139 | printf(" 7 | Play next track\n"); 140 | if (now_playing != NULL && now_playing->song != NULL) 141 | printf(" 8 | Show more information about the song playing\n"); 142 | printf(" -1 | Exit music player\n"); 143 | printf("----------------------------------------------------------------------\n"); 144 | printf(" Enter your choice below\n"); 145 | } 146 | 147 | void show_all_songs_raw() 148 | { 149 | for (int i = 0; i < MAX_SONG_POOL && song_pool[i] != NULL; i++) 150 | printf("%-1d %-3s %-3s %-3d %0.2lfmin\n", (i + 1), song_pool[i]->title, song_pool[i]->album, song_pool[i]->year, song_pool[i]->duration); 151 | } 152 | 153 | void show_playlist() 154 | { 155 | if (does_playlist_exist()) 156 | { 157 | printf("\n----------------------------------------------------------------------\n"); 158 | printf(" YOUR PLAYLIST\n"); 159 | printf("----------------------------------------------------------------------\n"); 160 | printf(" Title | Duration\n"); 161 | printf("----------------------------------------------------------------------\n"); 162 | node_ptr current = header_node; 163 | while (current != NULL && current->song != NULL) 164 | { 165 | node_ptr next = current->next_song; 166 | printf(" %-48.48s | %2.2lf min\n", current->song->title, current->song->duration); 167 | current = next; 168 | } 169 | 170 | printf("----------------------------------------------------------------------"); 171 | } 172 | else 173 | { 174 | printf("\nYou haven't created a playlist yet.\n"); 175 | } 176 | } 177 | 178 | void pagewise_song_display(int step) 179 | { 180 | printf("\n----------------------------------------------------------------------\n"); 181 | printf(" SONGS LIST\n"); 182 | printf("----------------------------------------------------------------------\n"); 183 | printf(" # | Title | Duration\n"); 184 | printf("----------------------------------------------------------------------\n"); 185 | for (int i = step - 10; i < step && song_pool[i] != NULL; i++) 186 | { 187 | printf(" %2d | %-48.48s | %2.2lf min\n", (i + 1), song_pool[i]->title, song_pool[i]->duration); 188 | } 189 | printf("----------------------------------------------------------------------\n"); 190 | printf("[Enter -2 to go to prev page] | Page %d | [Enter -1 to go to next page]\n", ((int)step / 10)); 191 | printf("----------------------------------------------------------------------\n"); 192 | printf(" <<<< Enter 0 to go back to main menu.\n"); 193 | 194 | printf("----------------------------------------------------------------------\n"); 195 | printf(" Enter your choice below\n"); 196 | } 197 | 198 | int song_selector() 199 | { 200 | int song_number = -1; 201 | int step = 10; 202 | while (song_number < 0 || song_number > pool_insert_index) 203 | { 204 | pagewise_song_display(step); 205 | char input[MAX_STRING_SIZE]; 206 | scanf("%s", input); 207 | 208 | if (!sscanf(input, "%d", &song_number)) 209 | { 210 | system("clear"); 211 | printf("You seem to have entered an invalid input.\nReturning to main menu."); 212 | return 0; 213 | } 214 | 215 | if (song_number == -2) 216 | { 217 | if (step > 10) 218 | { 219 | step -= 10; 220 | system("clear"); 221 | } 222 | else 223 | { 224 | system("clear"); 225 | printf("\nThis itself is the first page"); 226 | } 227 | } 228 | else if (song_number == -1) 229 | { 230 | if (step < ceil(pool_insert_index / 10.0) * 10) 231 | { 232 | step += 10; 233 | system("clear"); 234 | } 235 | else 236 | { 237 | system("clear"); 238 | printf("\nThis is the last page"); 239 | } 240 | } 241 | else if (song_number < -2 || song_number > pool_insert_index) 242 | { 243 | system("clear"); 244 | printf("\nENTER A VALID CHOICE\n"); 245 | } 246 | } 247 | 248 | return song_number; 249 | } 250 | 251 | Song *createSong(const char *title, const char *album, const short int year, const double duration, const char *uri, const char *id) 252 | { 253 | Song *temp = malloc(sizeof(Song)); 254 | strcpy(temp->title, title); 255 | strcpy(temp->album, album); 256 | strcpy(temp->uri, uri); 257 | strcpy(temp->id, id); 258 | temp->year = year; 259 | temp->duration = duration; 260 | pool_insert_index++; 261 | return temp; 262 | } 263 | 264 | //Allocates memory for a new playlist and prompts user to add a song to it 265 | void create_playlist() 266 | { 267 | int song_number = 0, i = 0; 268 | 269 | node_ptr temp = (node_ptr)malloc(sizeof(PlaylistNode)); 270 | printf("\nPick the song you want to add to your new playlist\n"); 271 | song_number = song_selector(); 272 | if (song_number > 0 && song_number <= 100) 273 | { 274 | temp->song = song_pool[song_number - 1]; 275 | temp->prev_song = NULL; 276 | temp->next_song = NULL; 277 | header_node = temp; 278 | now_playing = temp; 279 | 280 | system("clear"); 281 | printf("---\n%s has been added to your new playlist.\n---", song_pool[song_number - 1]->title); 282 | } 283 | else if (song_number == 0) 284 | { 285 | system("clear"); 286 | } 287 | else 288 | { 289 | printf("\nThere was a problem while handling your request, try again.\n"); 290 | } 291 | } 292 | 293 | //Prompts user to pick a song from the pool and add it to the existing playlist 294 | void add_to_playlist() 295 | { 296 | int song_number = 0; 297 | int step = 10; 298 | printf("\nPick the song you want to add\n"); 299 | song_number = song_selector(); 300 | if (song_number > 0 && song_number <= pool_insert_index) 301 | { 302 | node_ptr new_node = (node_ptr)malloc(sizeof(PlaylistNode)); 303 | node_ptr last = header_node; 304 | new_node->song = song_pool[song_number - 1]; 305 | new_node->next_song = NULL; 306 | 307 | /* 4. If the Linked List is empty, then make the new 308 | node as head */ 309 | if (header_node == NULL) 310 | { 311 | new_node->prev_song = NULL; 312 | header_node = new_node; 313 | now_playing = new_node; 314 | } 315 | else 316 | { 317 | //Traverse till the last node 318 | while (last->next_song != NULL) 319 | last = last->next_song; 320 | 321 | last->next_song = new_node; 322 | new_node->prev_song = last; 323 | } 324 | system("clear"); 325 | printf("%s has been added to your playlist.\n", song_pool[song_number - 1]->title); 326 | } 327 | else if (song_number == 0) 328 | { 329 | system("clear"); 330 | } 331 | else 332 | { 333 | printf("\nThere was a problem while handling your request.\n"); 334 | } 335 | } 336 | 337 | /** CSV Parser that maps a data set of upto songs onto the song pool 338 | Songs must be present in the root directory at rawdata.csv 339 | */ 340 | void readFromCSV() 341 | { 342 | FILE *file = fopen("rawdata.csv", "r"); 343 | char line[1000]; 344 | int i = 0; 345 | 346 | if (file == NULL) 347 | { 348 | perror("******\nUnable to load songs from data source"); 349 | printf("Please check if rawdata.csv exists at the root directory of the application.\n"); 350 | printf("You can still enter songs manually.\n******\n"); 351 | printf("Error Message"); 352 | } 353 | else 354 | { 355 | char songtitle[MAX_STRING_SIZE]; 356 | char releaseDate[MAX_STRING_SIZE]; 357 | int durationms; 358 | double duration = 0.0; 359 | char id[MAX_STRING_SIZE]; 360 | char album[MAX_STRING_SIZE]; 361 | char uri[MAX_STRING_SIZE]; 362 | int year; 363 | while (fgets(line, sizeof(line), file) && pool_insert_index < MAX_SONG_POOL) 364 | { 365 | char *token; 366 | token = strtok(line, ","); //tokenizes current line with delimiter ',' and returns the first substring 367 | if (token == NULL) 368 | continue; 369 | strcpy(songtitle, token); 370 | token = strtok(NULL, ","); // get the next token 371 | strncpy(releaseDate, token + 1, 4); 372 | sscanf(releaseDate, "%d", &year); 373 | token = strtok(NULL, ","); 374 | char temp[MAX_STRING_SIZE]; 375 | strncpy(temp, token + 1, 6); 376 | sscanf(temp, "%d", &durationms); 377 | duration = durationms / 60000.0; 378 | token = strtok(NULL, ","); // get the next token 379 | strcpy(id, token); 380 | token = strtok(NULL, ","); // get the next token 381 | strcpy(album, token); 382 | token = strtok(NULL, ","); // get the next token 383 | strcpy(uri, token); 384 | token = strtok(NULL, ","); // get the next token 385 | //printf("Song read : %s %s\n",songname,durationm); 386 | if (i == 0) 387 | { 388 | i++; 389 | continue; 390 | } 391 | song_pool[i - 1] = createSong(songtitle, album, year, duration, uri, id); 392 | i++; 393 | } 394 | } 395 | 396 | //printf("%d Songs added.\n\n", i); 397 | fclose(file); 398 | } 399 | 400 | //Function that allows the user to create a song of their own 401 | void user_song_input() 402 | { 403 | int add_another = 1; 404 | char songname[MAX_STRING_SIZE]; 405 | int year; 406 | int durationms; 407 | char id[MAX_STRING_SIZE]; 408 | char album[MAX_STRING_SIZE]; 409 | char uri[MAX_STRING_SIZE] = "spotify:track:"; 410 | double duration = 0.0; 411 | 412 | while (add_another && pool_insert_index < MAX_SONG_POOL) 413 | { 414 | system("clear"); 415 | printf("\nEnter the details of the song you want to create.\n[ Don't give spaces between each word, use _ instead\n"); 416 | 417 | printf("Title: "); 418 | scanf("%s", songname); 419 | printf("Album Name: "); 420 | scanf("%s", album); 421 | printf("Year of release: "); 422 | if (!(scanf("%d", &year))) 423 | { 424 | printf("INVALID INPUT ENTERED\n"); 425 | sleep(1); 426 | break; 427 | } 428 | printf("Duration(in s): "); 429 | if (!(scanf("%d", &durationms))) 430 | { 431 | printf("INVALID INPUT ENTERED\n"); 432 | sleep(1); 433 | break; 434 | } 435 | duration = durationms / 60; 436 | printf("Song ID: "); 437 | scanf("%s", id); 438 | strcat(uri, id); 439 | song_pool[pool_insert_index] = createSong(songname, album, year, duration, uri, id); 440 | printf("\nThe song %s has been created.\n\n", songname); 441 | printf("\nDo you want to create another song?\n(Enter 1 for yes and 0 for no) : "); 442 | scanf("%d", &add_another); 443 | } 444 | system("clear"); 445 | } 446 | 447 | //Helper function to delete the playlist created and free all resources taken up by PlaylistNodes 448 | bool delete_playlist() 449 | { 450 | if (header_node != NULL) 451 | { 452 | node_ptr current = header_node; 453 | while (current != NULL) 454 | { 455 | node_ptr next = current->next_song; 456 | free(current); 457 | current = next; 458 | } 459 | header_node = NULL; 460 | now_playing = NULL; 461 | return true; 462 | } 463 | return false; 464 | } 465 | 466 | //Frees resources that had been dynamically allocated 467 | void free_all_memory() 468 | { 469 | delete_playlist(); 470 | for (int i = 0; i < MAX_SONG_POOL && song_pool[i] != NULL; i++) 471 | free(song_pool[i]); 472 | printf("\n---END---"); 473 | 474 | //Generate a 2 second delay 475 | sleep(2); 476 | } 477 | 478 | int main() 479 | { 480 | int userChoice = 0; 481 | char *terminate = "X"; 482 | int wrong_choice_count = 0; 483 | system("clear"); 484 | readFromCSV(); 485 | while (userChoice != -1) 486 | { 487 | switch (userChoice) 488 | { 489 | case 0: 490 | { //Show menu options 491 | main_menu(); 492 | break; 493 | } 494 | case 1: 495 | { 496 | system("clear"); 497 | if (pool_insert_index >= MAX_SONG_POOL) 498 | { 499 | printf("Cannot add more songs.\n"); 500 | } 501 | 502 | user_song_input(); 503 | break; 504 | } 505 | case 2: 506 | { 507 | system("clear"); 508 | //show_all_songs(); 509 | int user_song_selection = song_selector(); 510 | system("clear"); 511 | break; 512 | } 513 | case 3: 514 | { 515 | system("clear"); 516 | if (does_playlist_exist()) 517 | { 518 | printf("---"); 519 | if (delete_playlist()) 520 | printf("\nThe playlist was successfully deleted.\n"); 521 | else 522 | printf("\nYou haven't created a playlist yet. Nothing to delete\n"); 523 | 524 | printf("---"); 525 | } 526 | else 527 | create_playlist(); 528 | break; 529 | } 530 | case 4: 531 | { 532 | system("clear"); 533 | add_to_playlist(); 534 | break; 535 | } 536 | case 5: 537 | { 538 | system("clear"); 539 | show_playlist(); 540 | break; 541 | } 542 | case 6: 543 | { 544 | system("clear"); 545 | play_prev_song(); 546 | break; 547 | } 548 | case 7: 549 | { 550 | system("clear"); 551 | play_next_song(); 552 | break; 553 | } 554 | case 8: 555 | { 556 | system("clear"); 557 | show_song_details(); 558 | break; 559 | } 560 | 561 | default: 562 | { 563 | if (wrong_choice_count == 3) 564 | { 565 | system("clear"); 566 | printf("Please enter a valid option or the program will terminate.\n"); 567 | } 568 | if (wrong_choice_count > 3) 569 | { 570 | system("clear"); 571 | printf("Sorry you have exceeded the maximum number of retries, terminating.."); 572 | free_all_memory(); 573 | exit(1); 574 | } 575 | else 576 | { 577 | system("clear"); 578 | printf("Please enter a valid option from the main menu below\n"); 579 | } 580 | wrong_choice_count++; 581 | break; 582 | } 583 | } 584 | if (userChoice != 0) 585 | { 586 | main_menu(); 587 | } 588 | 589 | char input[MAX_STRING_SIZE]; 590 | scanf("%s", input); 591 | 592 | if (!sscanf(input, "%d", &userChoice)) 593 | { 594 | system("clear"); 595 | printf("----\nINVALID INPUT\n"); 596 | userChoice = 0; 597 | wrong_choice_count++; 598 | if (wrong_choice_count > 3) 599 | { 600 | printf("Sorry you have exceeded the maximum number of retries, terminating.."); 601 | free_all_memory(); 602 | exit(1); 603 | } 604 | continue; 605 | } 606 | } 607 | free_all_memory(); 608 | 609 | return 0; 610 | } -------------------------------------------------------------------------------- /Phonebook-C-Project/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](https://github.com/mrbhatt2348/C-projects/blob/master/Phonebook-C-Project/screenshots/front.jpg) 7 | 8 | ### 02. Main Page 9 | ![Main](https://github.com/mrbhatt2348/C-projects/blob/master/Phonebook-C-Project/screenshots/main.jpg) 10 | -------------------------------------------------------------------------------- /Phonebook-C-Project/abc.txt: -------------------------------------------------------------------------------- 1 | dv sjv 2 | -------------------------------------------------------------------------------- /Phonebook-C-Project/phonebook.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){ 315 | ch=getch(); 316 | if(ch!=13 && ch!=8){ 317 | printf("%c",w); 318 | pass[i]=ch; 319 | i++; 320 | } 321 | } 322 | pass[i]='\0'; 323 | if(strcmp(pass,passwords)==0){ 324 | gotoxy(30,6); 325 | printf("CORRECT PASSWORD."); 326 | Sleep(1000); 327 | menu(); 328 | } 329 | else{ 330 | gotoxy(30,6); 331 | printf("You entered the wrong password."); 332 | Sleep(700); 333 | system("cls"); 334 | password(); 335 | } 336 | 337 | } 338 | 339 | 340 | void menu(){ 341 | system("cls"); 342 | gotoxy(30,1); 343 | 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"); 344 | gotoxy(31,4); 345 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 1.Add New"); 346 | gotoxy(31,7); 347 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 2.Search"); 348 | gotoxy(31,10); 349 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 3.List"); 350 | gotoxy(31,13); 351 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 4.Modify"); 352 | gotoxy(31,16); 353 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 5.Delete"); 354 | gotoxy(31,19); 355 | printf("\xB3\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB 6.Exit"); 356 | switch(getch()){ 357 | case '1': 358 | namefun(); 359 | break; 360 | case '2': 361 | searchfun(); 362 | break; 363 | case '3': 364 | listfun(); 365 | break; 366 | case '4': 367 | modifyfun(); 368 | break; 369 | case '5': 370 | deletefun(); 371 | break; 372 | case '6': 373 | exitfun(); 374 | break; 375 | default: 376 | system("cls"); 377 | printf("Invalid Enter."); 378 | getch(); 379 | } 380 | } 381 | 382 | 383 | -------------------------------------------------------------------------------- /Phonebook-C-Project/phonebook.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Phonebook-C-Project/phonebook.exe -------------------------------------------------------------------------------- /Phonebook-C-Project/sample.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 | -------------------------------------------------------------------------------- /Phonebook-C-Project/screenshots/front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Phonebook-C-Project/screenshots/front.jpg -------------------------------------------------------------------------------- /Phonebook-C-Project/screenshots/main.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Phonebook-C-Project/screenshots/main.jpg -------------------------------------------------------------------------------- /Playback Speed Calculator/Readme.md: -------------------------------------------------------------------------------- 1 | # Playback Speed Calculator 2 | 3 | This calculator will help to know the time it will take to watch the complete video at any speed. 4 | 5 | # Video Demo 6 | 7 | ## Demo 8 | 9 | 12 | 13 | 14 | https://user-images.githubusercontent.com/88226411/195318740-fa5755c7-8e57-471c-844e-e1e3ad49fdc9.mp4 15 | 16 | -------------------------------------------------------------------------------- /Playback Speed Calculator/sourceCode.c: -------------------------------------------------------------------------------- 1 | //including header files 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | //Declaring necessary variables 8 | int hours, minutes, hours_to_minutes, videoLength, minutes_to_hours, actualLength, remaining_minutes ; 9 | float playbackSpeed; 10 | 11 | //Taking hours as input 12 | printf("\nEnter the hours of the video: "); 13 | scanf("%d", &hours); 14 | 15 | //Taking minutes as input 16 | printf("and the minutes: "); 17 | scanf("%d", &minutes); 18 | 19 | //Taking Playback speed as input 20 | printf("\nEnter Playback Speed in which you want to watch the video: "); 21 | scanf("%f", &playbackSpeed); 22 | 23 | 24 | //Calculation of playback speed 👇 25 | 26 | //Converting hours to minutes 27 | hours_to_minutes = hours*60; 28 | 29 | //Calculating original length of video 30 | videoLength = hours_to_minutes + minutes; 31 | 32 | //Calculating actual length of video after applying playback speed 33 | actualLength = videoLength/playbackSpeed; 34 | 35 | //Converting minutes to hours 36 | minutes_to_hours = actualLength/60; 37 | remaining_minutes = actualLength%60; 38 | 39 | //Giving the resultant time as output 40 | printf("\nIt will take %d hours and %d minutes at %.2f playback speed to watch the video.\n\n", minutes_to_hours, remaining_minutes, playbackSpeed); 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Are you interested in C and its projects 2 | 3 | ## As we all know we have to learn C to increase our programming fundamentals. So lets create some awesome using this awesome language and fill this repo with C projects together. 4 | 5 | ### Want to Contribute😎: 6 | Refer to contributing.md

7 | 8 | Thanks to all the people who have contributed: 9 | 10 | ![Contributors](https://contributors-img.web.app/image?repo=Rancho2002/C-projects) 11 | 12 | 13 | Don't forget to follow [@Rancho2002](https://www.github.com/rancho2002) ⭐ 14 | 15 | 16 | -------------------------------------------------------------------------------- /Snake, Water, Gun game/readme.md: -------------------------------------------------------------------------------- 1 | # About this project 2 | This project is a game. Where user can play snake, water, gun game with computer. 3 | ### Snake, Water, Gun game: 4 | if user choose Snake and computer choose Gun, computer win but if computer choose water computer lose 5 | if user choose Gun and computer choose water, computer win but if computer choose Snake computer win ... and this game continues. 6 | 7 | ## Video Demo 8 | https://user-images.githubusercontent.com/96330400/194870769-1ade2a17-4d66-4db6-aab1-0a00343ce482.mp4 9 | 10 | -------------------------------------------------------------------------------- /Snake, Water, Gun game/snake_game.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int gameValue(char comp, char me) 6 | { 7 | // 1st person can chose 3 items in 3 any ways 8 | // 2nd person also pick any items in 3 ways... 9 | // so it 3x3 = 9 ways! that mean 9 outcomes in this game! 10 | 11 | if (comp == me) 12 | { 13 | return 0; 14 | } // ss,ww,gg 15 | 16 | // snake- 17 | else if (me == 's' && comp == 'w') 18 | { 19 | return 1; 20 | } 21 | 22 | else if (me == 's' && comp == 'g') 23 | { 24 | return -1; 25 | } 26 | 27 | // water- 28 | 29 | else if (me == 'w' && comp == 's') 30 | { 31 | return -1; 32 | } 33 | else if (me == 'w' && comp == 'g') 34 | { 35 | return 1; 36 | } 37 | 38 | // gun- 39 | 40 | else if (me == 'g' && comp == 'w') 41 | { 42 | return -1; 43 | } 44 | else if (me == 'g' && comp == 's') 45 | { 46 | return 1; 47 | } 48 | } 49 | 50 | int main() 51 | { 52 | int num; 53 | srand(time(0)); 54 | num = rand() % 100 + 1; 55 | 56 | char comp, me; 57 | 58 | if (num < 33) 59 | { 60 | comp = 's'; 61 | } 62 | else if (num > 33 && num < 66) 63 | { 64 | comp = 'g'; 65 | } 66 | else 67 | { 68 | comp = 'w'; 69 | } 70 | label: 71 | printf("Enter 's' for snake, 'g' for gun & 'w' for water : "); 72 | fflush(stdin); 73 | scanf("%c", &me); 74 | 75 | int result = gameValue(comp, me); 76 | 77 | if (result == 1) 78 | { 79 | printf("Congratulations!!! You Won!\n"); 80 | } 81 | else if (result == -1) 82 | { 83 | printf("Alas!!! You Lost!\n"); 84 | } 85 | else if (result == 0) 86 | { 87 | printf("It's a tie.\n"); 88 | } 89 | else 90 | { 91 | goto label; 92 | } 93 | printf("You chose : %c\n", me); 94 | printf("Computer chose : %c\n", comp); 95 | return 0; 96 | } 97 | -------------------------------------------------------------------------------- /Space, newline ommiter/compress.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Space, newline ommiter/file_compressor.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | FILE *fptr1,*fptr2; 5 | fptr1=fopen("index.html","r"); 6 | char text=fgetc(fptr1); 7 | if(fptr1==NULL) 8 | printf("Cannot Open Target File."); 9 | else 10 | { 11 | fptr2=fopen("compress.txt","w"); 12 | while(text!=EOF){ 13 | fptr2=fopen("compress.txt","a"); 14 | if(text==' ' || text=='\n') 15 | { 16 | text=fgetc(fptr1); 17 | continue; 18 | } 19 | else 20 | fputc(text,fptr2); 21 | text=fgetc(fptr1); 22 | } 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Space, newline ommiter/file_compressor.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/Space, newline ommiter/file_compressor.exe -------------------------------------------------------------------------------- /Space, newline ommiter/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Space, newline ommiter/readme.md: -------------------------------------------------------------------------------- 1 | # About the project 2 | 3 | This project can omit all the space and newlines from a file and writes a new compressed file. 4 | 5 | ## Video Demo 6 | https://user-images.githubusercontent.com/96330400/194936766-86bfe7bc-0c1e-4c5f-a50d-132626296865.mp4 7 | 8 | -------------------------------------------------------------------------------- /Tic-Tac-Toe/README.md: -------------------------------------------------------------------------------- 1 | 2 | ✦ Tic-Tac-Toe 2-player game( C programmed) using basic C functions. 3 | ✦ User can now know more rules by pressing y/Y which will be redirected to link 4 | ✦ User will get two options to either start game or view the LeaderBoard. 5 | ✦ On pressing 1, users can enter their usernames,afterwhich player1 will be allowed to choose X or 0 and then the users enter the gaming area to make moves using numeric keypad. 6 | ✦ First user to get three spaces in a row/column or diagonally wins! 7 | ✦ On pressing 2, a LEADERBOARD will be shown of the users played on a particular system, after which users can enter the gaming area on pressing 1 or by pressing any other key, they can end the game and come back later. 8 | 9 | -------------------------------------------------------------------------------- /Tic-Tac-Toe/score.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Tic-Tac-Toe/tic-tac-toe.c: -------------------------------------------------------------------------------- 1 | /* 2 | This code has been compiled in Code::Blocks 16.01 IDE on Windows 10 3 | Author:- Mishal Shah 4 | */ 5 | #include 6 | #include 7 | #include 8 | #include 9 | #ifdef _WIN32 10 | #define OS "nt" 11 | #elif __unix__ 12 | #define OS "posix" 13 | #endif 14 | #define TRUE 1 15 | #define FALSE 0 16 | 17 | void board(char x, char o, unsigned char *u1, unsigned char *u2, char *a); // 2D Graphics on CLI 18 | void rules(); // Prints rule page on CLI 19 | int checkforwin(char *a); // Checks wether a player won 20 | bool decision(char *x, char *o, unsigned char *u1); // points player to mark X or mark 0 21 | int main() 22 | { 23 | FILE *p; 24 | char x,o; 25 | p=fopen("score.txt","a+"); 26 | fclose(p); 27 | char a[9]={'1','2','3','4','5','6','7','8','9'}; 28 | char u1[50],u2[50]; 29 | int player=1; 30 | int choice,score=-1; 31 | char symbol,re; 32 | char start,dec; 33 | int s; 34 | if (OS=="nt") 35 | system("color 09"); 36 | rules(); 37 | printf("\n\nType 1 to start the game:-\nType 2 to view leader board:-\n"); 38 | scanf("%d",&s); 39 | switch(s) { 40 | case 1: 41 | do { 42 | p=fopen("score.txt", "a+"); 43 | printf("\nEnter name of player1: "); 44 | scanf("%s",u1); 45 | fprintf(p,"\n%s",u1); 46 | printf("Enter name of player2: "); 47 | scanf("%s",u2); 48 | fprintf(p,"\t%s",u2); 49 | fclose(p); 50 | !strcmp(u1,u2) ? printf("Enter names of different players!\n\n") : FALSE; 51 | } while(!strcmp(u1,u2)); 52 | decision(&x, &o, u1); 53 | if (OS=="nt") 54 | system("color fc"); 55 | board(x,o, u1, u2, a); 56 | do { 57 | player=((player%2)?1:2); 58 | if(player==1) 59 | printf("%s Type any digit from 1-9 to fill your response:- ",u1); 60 | else 61 | printf("%s Type any digit from 1-9 to fill your response:- ",u2); 62 | scanf("%d",&choice); 63 | symbol=((player==1)?x:o); 64 | if(choice==1 && a[0]=='1') 65 | a[0]=symbol; 66 | else if(choice==2 && a[1]=='2') 67 | a[1]=symbol; 68 | else if(choice==3 && a[2]=='3') 69 | a[2]=symbol; 70 | else if(choice==4 && a[3]=='4') 71 | a[3]=symbol; 72 | else if(choice==5 && a[4]=='5') 73 | a[4]=symbol; 74 | else if(choice==6 && a[5]=='6') 75 | a[5]=symbol; 76 | else if(choice==7 && a[6]=='7') 77 | a[6]=symbol; 78 | else if(choice==8 && a[7]=='8') 79 | a[7]=symbol; 80 | else if(choice==9 && a[8]=='9') 81 | a[8]=symbol; 82 | else { 83 | printf("Wrong Selection\n"); 84 | player--; 85 | } 86 | score=checkforwin(a); 87 | player++; 88 | board(x, o, u1, u2, a); 89 | } while(score == -1); 90 | p=fopen("score.txt","a+"); 91 | if(score==1) { 92 | if(player==2){ 93 | printf("\n\nPlayer1 %s Wins!\n\n",u1); 94 | fprintf(p,"\t%s",u1); 95 | getchar(); 96 | } 97 | else { 98 | printf("\n\nPlayer2 %s Wins!\n\n",u2);fprintf(p,"\t%s",u2); 99 | getchar(); 100 | } 101 | fclose(p); 102 | } 103 | else { 104 | printf("\n\nGame Draws!\n\n");fprintf(p,"\t%s","DRAW"); 105 | getchar(); 106 | } 107 | break; 108 | case 2: 109 | if (OS=="nt") 110 | system("cls"); 111 | if (OS=="posix") 112 | system("clear"); 113 | printf("\n\n"); 114 | printf("\tLEADERBOARD\n\n"); 115 | char c; 116 | p=fopen("score.txt","r"); 117 | while((c=getc(p))!=EOF) { 118 | printf("%c",c); 119 | } 120 | fclose(p); 121 | getchar(); 122 | break; 123 | default: 124 | printf("\n\nShould have typed 1 to play the game!\nHope to see you back soon!\n\n"); 125 | getchar(); 126 | break; 127 | } 128 | } 129 | int checkforwin(char *a) 130 | { 131 | if(a[0]==a[1] && a[1]==a[2]) 132 | return 1; 133 | else if(a[3]==a[4] && a[4]==a[5]) 134 | return 1; 135 | else if(a[6]==a[7] && a[7]==a[8]) 136 | return 1; 137 | else if(a[0]==a[3] && a[3]==a[6]) 138 | return 1; 139 | else if(a[1]==a[4] && a[4]==a[7]) 140 | return 1; 141 | else if(a[2]==a[5] && a[5]==a[8]) 142 | return 1; 143 | else if(a[0]==a[4] && a[4]==a[8]) 144 | return 1; 145 | else if(a[2]==a[4] && a[4]==a[6]) 146 | return 1; 147 | else if(a[0]!='1' && a[1]!='2' && a[2]!='3' && a[3]!='4' && a[4]!='5' && a[5]!='6' && a[6]!='7' && a[7]!='8' && a[8]!='9') 148 | return 0; 149 | else 150 | return -1; 151 | } 152 | 153 | void board(char x, char o, unsigned char *u1, unsigned char *u2, char *a) 154 | { 155 | int i; 156 | if (OS=="nt") 157 | system("cls"); 158 | if (OS=="posix") 159 | system("clear"); 160 | printf("\tTic-Tac-Toe\n\n"); 161 | printf("\n\n"); 162 | printf("%s:- (%c)\n%s:- (%c)\n\n\n",u1,x,u2,o); 163 | 164 | printf(" %c | %c | %c\n",a[0],a[1],a[2]); 165 | printf(" | | \n"); 166 | printf("----|----|----\n"); 167 | printf(" | | \n"); 168 | printf(" %c | %c | %c\n",a[3],a[4],a[5]); 169 | printf(" | | \n"); 170 | printf("----|----|----\n"); 171 | printf(" %c | %c | %c\n",a[6],a[7],a[8]); 172 | printf(" | | \n"); 173 | } 174 | void rules() 175 | { 176 | char link; 177 | printf("\tTic-Tac-Toe\n\n"); 178 | printf("Welcome to the most played 2D game and a sort of fun using X and O\n\n"); 179 | printf("Rules:-\n"); 180 | printf("\n1:Each player will be entering the number to put respective X or O in the desired position"); 181 | printf("\n2:Player who gets a combination of 3 same characters either diagonal or horizontally or \n vertically will be declared as the winner"); 182 | printf("\n\nEnjoy the game! Be a Winner!\n\n"); 183 | printf("For more clarifications press Y else type any other character:- "); 184 | scanf("%c",&link); 185 | if(link=='y' || link=='Y') 186 | { 187 | if (OS=="nt") 188 | system("start http://www.wikihow.com/Play-Tic-Tac-Toe"); 189 | if (OS=="posix") 190 | system("firefox http://www.wikihow.com/Play-Tic-Tac-Toe"); 191 | } 192 | 193 | } 194 | bool decision(char *x, char *o, unsigned char *u1) 195 | { 196 | char dec; 197 | printf("\n\n"); 198 | do { 199 | printf("Player1 %s choose the X or 0:",u1); 200 | dec=getchar(); 201 | scanf("%c", &dec); 202 | } while(dec!='X' && dec!='x' && dec!='0'); 203 | if (dec=='X' || dec=='x') { 204 | *x='X'; 205 | *o='0'; 206 | } 207 | else { 208 | *x='0'; 209 | *o='X'; 210 | } 211 | return 1; 212 | } 213 | -------------------------------------------------------------------------------- /multiplication table generator/multiplication_table.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int range,num; 5 | printf("Enter the number of which the multiplication table you want : "); 6 | scanf("%d",&num); 7 | printf("Enter the range of the multiplication table e.g. 10 : "); 8 | scanf("%d",&range); 9 | FILE *fptr; 10 | char *s="table.txt"; 11 | fptr=fopen(s,"w"); 12 | for(int i=1;i<=range;i++){ 13 | fprintf(fptr,"%d X %d = %d\n",num,i,num*i); 14 | } 15 | printf("\nMultiplication Table of %d generated successfully.\n",num); 16 | fclose(fptr); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /multiplication table generator/multiplication_table.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rancho2002/C-projects/b63485b91417711674cad31229b70a4cc196cc6e/multiplication table generator/multiplication_table.exe -------------------------------------------------------------------------------- /multiplication table generator/readme.md: -------------------------------------------------------------------------------- 1 | # About the Project 2 | This project can generate any multiplication table in a txt file 3 | 4 | # Video demo 5 | https://user-images.githubusercontent.com/96330400/194941601-641daf1f-9bc4-45dd-b6e2-e6fc9b4b9681.mp4 6 | 7 | -------------------------------------------------------------------------------- /multiplication table generator/table.txt: -------------------------------------------------------------------------------- 1 | 56 X 1 = 56 2 | 56 X 2 = 112 3 | 56 X 3 = 168 4 | 56 X 4 = 224 5 | 56 X 5 = 280 6 | 56 X 6 = 336 7 | 56 X 7 = 392 8 | 56 X 8 = 448 9 | 56 X 9 = 504 10 | 56 X 10 = 560 11 | -------------------------------------------------------------------------------- /my-name/arijit.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int row,col,i,j,space; 5 | row=6,col=6; 6 | for(i=1;i<=row;i++){ 7 | 8 | //! A 9 | for(j=1;j<=col;j++){ 10 | if(i==1 || j==1 || j==col|| i==row/2) 11 | printf("* "); 12 | else 13 | printf(" "); 14 | } 15 | 16 | for(j=1;j<=col;j++){ 17 | printf(" "); 18 | } 19 | 20 | 21 | //! R 22 | for(j=1;j<=col;j++){ 23 | if(i==1 || j==1 || i==row/2 || (j==col && i<=row/2) || (i==4 && j==4) || (i==5 && j==5) || (i==col && j==row)) 24 | printf("* "); 25 | else 26 | printf(" "); 27 | } 28 | 29 | for(j=1;j<=col;j++){ 30 | printf(" "); 31 | } 32 | 33 | //! I 34 | for(j=1;j<=col;j++){ 35 | if(i==1 || j==col/2 || i==row) 36 | printf("* "); 37 | else 38 | printf(" "); 39 | } 40 | for(j=1;j<=col;j++){ 41 | printf(" "); 42 | } 43 | 44 | //! J 45 | for(j=1;j<=col;j++){ 46 | if(i==1 || j==col || (j>=col/2-1 && i==row) || (i>row/2 && j==col/2-1)) 47 | printf("* "); 48 | else 49 | printf(" "); 50 | } 51 | 52 | for(j=1;j<=col;j++){ 53 | printf(" "); 54 | } 55 | 56 | //! I 57 | for(j=1;j<=col;j++){ 58 | if(i==1 || j==col/2 || i==row) 59 | printf("* "); 60 | else 61 | printf(" "); 62 | } 63 | 64 | for(j=1;j<=col;j++){ 65 | printf(" "); 66 | } 67 | 68 | //! T 69 | for(j=1;j<=col;j++){ 70 | if(j==col/2 || i==1) 71 | printf("* "); 72 | else 73 | printf(" "); 74 | } 75 | printf("\n"); 76 | } 77 | 78 | return 0; 79 | } -------------------------------------------------------------------------------- /password_generator/main.c: -------------------------------------------------------------------------------- 1 | //password generator using c language:- 2 | #include 3 | #include 4 | #include 5 | 6 | char passwordType[1]; 7 | 8 | int generateRandomNumbers(); 9 | 10 | char password[512]; 11 | 12 | char passwordLength[]; 13 | 14 | void printPassword(); 15 | 16 | int main() { 17 | 18 | //using srand with time to update random function to generate random numbers with time 19 | 20 | srand(time(NULL)); 21 | 22 | //A brief introduction 23 | 24 | printf("Welcome To Password Generator 2018\n"); 25 | 26 | printf("You can generate any kind of password you would like to...\n"); 27 | 28 | printf("Choose one of type below , you can choose both or triple too\n"); 29 | 30 | printf("a) a to z \nb) A to Z \nc) 0 to 9 \nd) special characters only\ne) anything\nf) a & b\ng) a & c\n" 31 | "h) a & d \ni) b & c \nj) b & d\nk) c & d\nl) a, b & c\nm) b, c & d\nn) a,c, &d " 32 | "\no)a,b &d\np)a,b,c &d\n"); 33 | 34 | printf("Enter any type given above(recommended == e)\n"); 35 | 36 | //getting user input on what type of password the need.. 37 | 38 | gets(passwordType); 39 | 40 | printf("Enter the password length\n"); 41 | 42 | //prompting user for password length 43 | 44 | gets(passwordLength); 45 | 46 | //calling printPassword function to display the password selected by the user from the above options 47 | 48 | printf("How many passwords do you want??\n"); 49 | 50 | char passwordTimes[1]; 51 | 52 | gets(passwordTimes); 53 | 54 | int m = atoi(passwordTimes); 55 | 56 | printf("%d",m); 57 | 58 | while (m>0){ 59 | 60 | printPassword(); 61 | 62 | m--; 63 | 64 | _sleep(1000); 65 | 66 | } 67 | 68 | char isAgain[1]; 69 | 70 | printf("Do you want to generate password again(y/n)\n"); 71 | 72 | //asking user if he/she wants to generate password again, if yes then calling main function again 73 | 74 | gets(isAgain); 75 | 76 | if (isAgain[0] == 'y'){ 77 | 78 | main(); 79 | 80 | } else if (isAgain[0] == 'n'){ 81 | 82 | printf("Thanks for using my password generator\n"); 83 | 84 | } else{ 85 | 86 | printf("Invalid input\n"); 87 | 88 | } 89 | 90 | 91 | return 0; 92 | 93 | } 94 | 95 | // This function generating random numbers to generate password 96 | 97 | int generateRandomNumbers(){ 98 | 99 | int random; 100 | 101 | int r; 102 | 103 | // based on passwordType the user needs, generating random numbers 104 | 105 | switch (passwordType[0]){ 106 | 107 | case 'a': 108 | 109 | random = (rand() % (122 + 1 - 97)) + 97; 110 | 111 | break; 112 | 113 | case 'b': 114 | 115 | random = (rand() % (90 + 1 - 65)) + 65; 116 | 117 | break; 118 | 119 | case 'c': 120 | 121 | random = (rand() % (57 + 1 - 48)) + 48; 122 | 123 | break; 124 | 125 | case 'd': 126 | 127 | while (1){ 128 | 129 | r = (rand() % (256 + 1 - 0)) + 0; 130 | 131 | if (((r<=47) && (r>=33)) || ((r<=64) && (r>=58)) || ((r<=96) && (r>=91)) || ((r<=175) && (r>=123)) || ((r<=254) && (r>=178))){ 132 | 133 | random = r; 134 | 135 | break; 136 | 137 | } 138 | 139 | } 140 | 141 | break; 142 | 143 | case 'e': 144 | 145 | random = (rand() % (126 + 1 - 33)) + 33; 146 | 147 | break; 148 | 149 | case 'f': 150 | 151 | while (1){ 152 | 153 | r = (rand() % (256 + 1 - 0)) + 0; 154 | 155 | if (((r<=90) && (r>=65)) || ((r<=122) && (r>=97))){ 156 | 157 | random = r; 158 | 159 | break; 160 | 161 | } 162 | 163 | } 164 | 165 | break; 166 | 167 | case 'g': 168 | 169 | while (1){ 170 | 171 | r = (rand() % (256 + 1 - 0)) + 0; 172 | 173 | if (((r<=57) && (r>=48)) || ((r<=122) && (r>=97))){ 174 | 175 | random = r; 176 | 177 | break; 178 | 179 | } 180 | 181 | } 182 | 183 | break; 184 | 185 | case 'h': 186 | 187 | while (1){ 188 | 189 | r = (rand() % (256 + 1 - 0)) + 0; 190 | 191 | if (((r<=122) && (r>=97)) ||((r<=47) && (r>=33)) || ((r<=64) && (r>=58)) || ((r<=96) && (r>=91)) || ((r<=175) && (r>=123)) || ((r<=254) && (r>=178))){ 192 | 193 | random = r; 194 | 195 | break; 196 | 197 | } 198 | 199 | } 200 | 201 | break; 202 | 203 | case 'i': 204 | 205 | while (1){ 206 | 207 | r = (rand() % (256 + 1 - 0)) + 0; 208 | 209 | if (((r<=90) && (r>=65)) || ((r<=57) && (r>=48))){ 210 | 211 | random = r; 212 | 213 | break; 214 | 215 | } 216 | 217 | } 218 | 219 | break; 220 | 221 | case 'j': 222 | 223 | while (1){ 224 | 225 | r = (rand() % (256 + 1 - 0)) + 0; 226 | 227 | if (((r<=90) && (r>=65)) ||((r<=47) && (r>=33)) || ((r<=64) && (r>=58)) || ((r<=96) && (r>=91)) || ((r<=175) && (r>=123)) || ((r<=254) && (r>=178))){ 228 | 229 | random = r; 230 | 231 | break; 232 | 233 | } 234 | 235 | } 236 | 237 | break; 238 | 239 | case 'k': 240 | 241 | while (1){ 242 | 243 | r = (rand() % (256 + 1 - 0)) + 0; 244 | 245 | if (((r<=57) && (r>=48)) || ((r<=47) && (r>=33)) || ((r<=64) && (r>=58)) || ((r<=96) && (r>=91)) || ((r<=175) && (r>=123)) || ((r<=254) && (r>=178))){ 246 | 247 | random = r; 248 | 249 | break; 250 | 251 | } 252 | 253 | } 254 | 255 | break; 256 | 257 | case 'l': 258 | 259 | while (1){ 260 | 261 | r = (rand() % (256 + 1 - 0)) + 0; 262 | 263 | if(((r<=122) && (r>=97)) || ((r<=90) && (r>=65)) || ((r<=57) && (r>=48))){ 264 | 265 | random = r; 266 | 267 | break; 268 | 269 | } 270 | 271 | } 272 | 273 | break; 274 | 275 | case 'm': 276 | 277 | while (1){ 278 | 279 | r = (rand() % (256 + 1 - 0)) + 0; 280 | 281 | if(((r<=90) && (r>=65)) || ((r<=57) && (r>=48)) || ((r<=47) && (r>=33)) || ((r<=64) && (r>=58)) || ((r<=96) && (r>=91)) || ((r<=175) && (r>=123)) || ((r<=254) && (r>=178))){ 282 | 283 | random = r; 284 | 285 | break; 286 | 287 | } 288 | 289 | } 290 | 291 | break; 292 | 293 | case 'n': 294 | 295 | while (1){ 296 | 297 | r = (rand() % (256 + 1 - 0)) + 0; 298 | 299 | if(((r<=122) && (r>=97)) || ((r<=57) && (r>=48)) || ((r<=47) && (r>=33)) || ((r<=64) && (r>=58)) || ((r<=96) && (r>=91)) || ((r<=175) && (r>=123)) || ((r<=254) && (r>=178))){ 300 | 301 | random = r; 302 | 303 | break; 304 | 305 | } 306 | 307 | } 308 | 309 | break; 310 | 311 | case 'o': 312 | 313 | while (1){ 314 | 315 | r = (rand() % (256 + 1 - 0)) + 0; 316 | 317 | if(((r<=122) && (r>=97)) || ((r<=90) && (r>=65)) || ((r<=47) && (r>=33)) || ((r<=64) && (r>=58)) || ((r<=96) && (r>=91)) || ((r<=175) && (r>=123)) || ((r<=254) && (r>=178))){ 318 | 319 | random = r; 320 | 321 | break; 322 | 323 | } 324 | 325 | } 326 | 327 | break; 328 | 329 | case 'p': 330 | 331 | while (1){ 332 | 333 | r = (rand() % (256 + 1 - 0)) + 0; 334 | 335 | if(((r<=122) && (r>=97)) || ((r<=90) && (r>=65)) || ((r<=57) && (r>=48)) || ((r<=47) && (r>=33)) || ((r<=64) && (r>=58)) || ((r<=96) && (r>=91)) || ((r<=175) && (r>=123)) || ((r<=254) && (r>=178))){ 336 | 337 | random = r; 338 | 339 | break; 340 | 341 | } 342 | 343 | } 344 | 345 | break; 346 | 347 | default: 348 | 349 | printf("Invalid Input so we are exiting you from program and starting again\n"); 350 | 351 | main(); 352 | 353 | } 354 | 355 | return random; 356 | 357 | } 358 | 359 | // Here is the main function which prints the password to the user 360 | 361 | void printPassword(){ 362 | 363 | int randomNumber; 364 | 365 | int k; 366 | 367 | //converting password length string to ineger to loop 368 | 369 | int length = atoi(passwordLength); 370 | 371 | //looping and generating random numbers and storing in password array 372 | 373 | for (k = 0; k < length; k++) { 374 | 375 | randomNumber = generateRandomNumbers(); 376 | 377 | password[k] = randomNumber; 378 | 379 | } 380 | 381 | for (int j = 0; j < length+19; j++) { 382 | 383 | printf("="); 384 | 385 | } 386 | 387 | printf("\n"); 388 | 389 | //Here Printing the password to the user 390 | 391 | printf("Your password is: %s", password); 392 | 393 | printf("\n"); 394 | 395 | for (int a = 0; a < length+19; a++) { 396 | 397 | printf("="); 398 | 399 | } 400 | 401 | printf("\n"); 402 | 403 | } 404 | -------------------------------------------------------------------------------- /password_generator/readme.md: -------------------------------------------------------------------------------- 1 | PASSWORD GENERATOR 2 | 3 | Rules for passwords: 4 | -at least 9 characters long and less then 15 characters 5 | -at least 2 numbers 6 | -at least 2 uppercase and 2 lowercase letters 7 | -at least 1 symbol 8 | -no common words (3,4 letter words) (Use a dictionary(text file)) [have 10 to 50 words] 9 | -old passwords not to be used again (write to text file, same as above) 10 | 11 | Create a menu -Generate a password (from the rules above) 12 | -must be able to enter a password 13 | 14 | About 15 | This application was created to show off the use of the C language with a strong emphasis on saving/loading, random sequence generation and checking uniqueness 16 | of generation. 17 | 18 | The application remembers state by saving and loading to a TXT file. 19 | 20 | Tools Used 21 | This program was written in C using the Visual Studio IDE. 22 | --------------------------------------------------------------------------------