Advertisement
alien_fx_fiend

Assorted Source Codes

Aug 19th, 2019
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 16.99 KB | None | 0 0
  1. CSS Radial Gradient;
  2. background: radial-gradient(#e66465, #9198e5);
  3. background: radial-gradient(closest-side, #3f87a6, #ebf8e1, #f69d3c);
  4. background: radial-gradient(circle at 100%, #333, #333 50%, #eee 75%, #333 75%);
  5. background: radial-gradient(ellipse at top, #e66465, transparent),
  6. radial-gradient(ellipse at bottom, #4d9f0c, transparent);
  7.  
  8. http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=138&lngWId=14
  9.  
  10. //**************************************
  11. // Name: Login Using a Text File in C
  12. // Description:While I'm writing my book on C programming I came across with the idea to include in my book topic on File Handling in C. The idea is to write a program using C as my programming language to store a username and password in a text file and create a login program that will ask the user to give the username and password. The program will search for the username and password that is already stored in our text file. In this example the name of the text file is users.txt. I
  13. If the username and password are correct and can be located in the text file the program will allow the user to access the system. But if username or password is incorrect the program will not allow the user to access the system. I hope you will find my work useful. Thank you.
  14. I am currently accepting programming work, it projects, school and application development.
  15. programming projects, thesis and capstone projects, IT consulting.
  16. work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
  17. My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
  18. My mobile number here in the Philippines is 09173084360.
  19. My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
  20. Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.
  21. My personal website is http://www.jakerpomperada.com
  22. // By: Jake R. Pomperada
  23. //**************************************
  24.  
  25. /* login.c
  26.  Author: Jake Rodriguez Pomperada,MAED-IT
  27.  Website: http://www.jakerpomperada.com
  28.  Emails: jakerpomperada@gmail.com and jakerpomperada@aol.com
  29.  Location : Bacolod City, Negros Occidental
  30.  Tool : Dev C++ Version 5.11
  31.  Date : January 7, 20193:46 PM Monday
  32. */
  33. #include <stdio.h>
  34. #include <conio.h>
  35. #include <stdlib.h>
  36. #include <string.h>
  37. void get_ID_and_PASS(char fileName[30],char *id,char *pass)
  38. {
  39. FILE *F = fopen(fileName,"r");
  40. if(F)
  41. {
  42. int count = 0;
  43. while(!feof(F))
  44. {
  45. char rawLine[50];
  46. fscanf(F,"%s",rawLine);
  47. if(!count++)
  48. strcpy(id,rawLine);
  49. else
  50. strcpy(pass,rawLine);
  51. }
  52. }else printf("Cannot open this file");
  53. fclose(F);
  54. }
  55. int main()
  56. {
  57. char fileName[30] = "users.txt";
  58. char userID[50],userPassW[50];
  59. char strID[50]="\0",strPASSW[50]="\0";
  60. char IDpref[50] = "user_id:\0",PASSWpref[50] = "password:\0";
  61. get_ID_and_PASS(fileName,userID,userPassW);
  62. char c;
  63. int pos = 0;
  64. printf("\n\n");
  65. printf("\tLOGIN SECURITY SYSTEM IN C USING TEXT FILES");
  66. printf("\n\n");
  67. printf("\tEnter User Name : ");
  68. scanf("%s",&strID);
  69. printf("\n");
  70. printf("\tEnter Your Password : ");
  71. do {
  72. c = getch();
  73. if( isprint(c) )
  74. {
  75. strPASSW[ pos++ ] = c;
  76. printf("%c", '*');
  77. }
  78. else if( c == 9 && pos )
  79. {
  80. strPASSW[pos--] = '\0';
  81. printf("%s", "\b \b");
  82. }
  83. } while( c != 13 );
  84. strcpy(strID,strcat(IDpref,strID));
  85. strcpy(strPASSW,strcat(PASSWpref,strPASSW));
  86. if (!strcmp(strID,userID)&&!strcmp(strPASSW,userPassW))
  87. {
  88. printf("\n\n");
  89. printf("\tCorrect Username And Password\n");
  90. printf("\n\n\tWelcome to the System\n\n");
  91. }
  92. else
  93. {
  94. printf("\n\n");
  95. printf("\tInvalid Username And Password. Try Again\n\n");
  96.  }
  97.  printf("\n\n");
  98.  printf("\tEND OF PROGRAM");
  99.  printf("\n\n");
  100.  system("pause");
  101. }
  102.  
  103. http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=14018&lngWId=3
  104.  
  105. //**************************************
  106. // Name: Binary read
  107. // Description:This code takes a string of ones and zeros and converts them into an integer.
  108. // By: Mike Smith
  109. //**************************************
  110.  
  111. #include <cstdio>
  112. #include <iostream>
  113. #include <string>
  114. using namespace std;
  115. int binaryToInt(string binary)
  116. {
  117.     int number = 0;
  118.    
  119.     for(unsigned char c: binary)
  120.     {
  121.         number<<=1;
  122.         number|=c-'0';
  123.     }
  124.    
  125.     return number;
  126. }
  127. int main (void)
  128. {
  129.     string binary = "101";
  130.     int number = binaryToInt(binary);
  131.     cout << binary << " is " << number << endl;
  132. }
  133.  
  134. http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=14016&lngWId=3
  135.  
  136. //**************************************
  137. // Name: EMPLOYEES CONTACT DETAILS SYSTEM IN C
  138. // Description:A very simple program that I wrote using C language to manage the information of the employee's contact details. I wrote this code in the Christmas Eve December 24, 2018, to make my day productive and enjoyable. I hope you will find my work useful. Merry Christmas to all you guys.
  139. I am currently accepting programming work, it projects, school
  140. programming projects, thesis and capstone projects, IT consulting
  141. work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
  142. My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
  143. My mobile number here in the Philippines is 09173084360.
  144. My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
  145. My personal website is http://www.jakerpomperada.com
  146. // By: Jake R. Pomperada
  147. //**************************************
  148.  
  149. /*employees_details.c
  150.  Authors: Jake R. Pomperada,MAED-IT
  151.  Emails: jakerpomperada@gmail.com
  152.  Tool : Dev C++ Version 5.11
  153.  Date : December 24, 2018 Monday 11:46 PM
  154.  */
  155. #include <stdio.h>
  156. #include <stdlib.h>
  157. #include <conio.h>
  158. #include <ctype.h>
  159. #include <string.h>
  160. main( )
  161. {
  162.     FILE *fp, *ft ;
  163.     char another, choice ;
  164.     struct employees
  165.     {
  166.         char emp_id[200];
  167.         char name[200];
  168.         char sex;
  169.         char address[200];
  170.         char telephone[200];
  171.         char mobile[200];
  172.         char email[200];
  173.        
  174.     };
  175.     struct employees info ;
  176.     char employee_id[200];
  177.     int flag=0;
  178.     long int recsize ;
  179.     fp = fopen ("RECORDS.DAT", "rb+" ) ;
  180.     if ( fp == NULL )
  181.     {
  182.         fp = fopen ("RECORDS.DAT", "wb+" ) ;
  183.         if ( fp == NULL )
  184.         {
  185.             puts ("Cannot open file" ) ;
  186.             exit(0) ;
  187.         }
  188.     }
  189.     recsize = sizeof ( info ) ;
  190.     while (1)
  191.     {
  192. system("CLS");
  193. printf("\n");
  194. printf("\n\t===========================================");
  195. printf("\n\t\tEMPLOYEES CONTACT DETAILS SYSTEM ");
  196. printf("\n\t\t\tCreated By");
  197. printf("\n\tJake R. Pomperada and Kristine T. Soberano");
  198. printf("\n\t===========================================");
  199.         printf("\n\n");
  200.         printf ( "\t1. ADD EMPLOYEE'S RECORD") ;
  201.         printf("\n");
  202.         printf ( "\t2. DISPLAY EMPLOYEE'S RECORD" ) ;
  203.         printf("\n");
  204.         printf ( "\t3. UPDATE EMPLOYEE'S RECORD" ) ;
  205.         printf("\n");
  206.         printf ( "\t4. SEARCH EMPLOYEE'S RECORD" ) ;
  207.         printf("\n");
  208.         printf ( "\t5. DELETE EMPLOYEE'S RECORD" ) ;
  209.         printf("\n");
  210.         printf ( "\t6. QUIT PROGRAM" );
  211.         printf("\n\n\n");
  212.         printf ("\tSELECT YOUR CHOICE : ") ;
  213.         fflush (stdin) ;
  214.         choice = getche() ;
  215.         switch (choice)
  216.         {
  217.             case '1' :
  218.                 fseek (fp, 0 ,SEEK_END) ;
  219.                 another = 'Y' ;
  220.                 while ( another == 'Y' )
  221.                 {
  222.                     system("cls");
  223.                     printf("\n\n");
  224. printf("\t=== Add New Employee's Record in the Database ===");
  225. printf("\n\n");
  226.                     printf("\tEnter Employees ID Number: ");
  227.                     scanf("%s",&info.emp_id);
  228.                     printf("\tEnter Employee's Name: ");
  229.                     fflush(stdin);
  230.                     gets(info.name);
  231.                     printf("\tEnter Gender M/F : ") ;
  232. info.sex = toupper(getche());
  233. printf("\n");
  234. printf("\tEnter Home Address: ");
  235. fflush(stdin);
  236.                     gets(info.address);
  237.                     printf("\tEnter Telephone Number: ");
  238. fflush(stdin);
  239.                     gets(info.telephone);
  240.                     printf("\tEnter Mobile Number : ");
  241. fflush(stdin);
  242.                     gets(info.mobile);
  243.                     printf("\tEnter Email Address : ");
  244.                     fflush(stdin);
  245.                     gets(info.email);
  246.                 fwrite (&info, recsize, 1, fp ) ;
  247.                     printf("\n\n");
  248.                     printf ("\n\tAdd another Record (Y/N) : ") ;
  249.                     fflush (stdin) ;
  250.                     another = toupper(getche()) ;
  251.                 }
  252.                 break ;
  253.             case '2' :
  254.             system("cls");
  255.                 rewind (fp);
  256.                 printf("\n\n");
  257. printf("\t=== View Employee's Records in the Database ===");
  258. printf("\n");
  259.         while ( fread ( &info, recsize, 1, fp ) == 1 )
  260.  {
  261.         printf("\n\tEmployee's ID Number : %s",info.emp_id);
  262.     printf("\n\tEmployee's Name: %s",info.name);
  263.         printf("\n\tGender: %c",info.sex);
  264.         printf("\n\tHome Address : %s",info.address);
  265.         printf("\n\tTelephone Number : %s",info.telephone);
  266.         printf("\n\tMobile Number : %s",info.mobile);
  267.         printf("\n\tEmail Address : %s",info.email);
  268.     printf("\n\n");
  269. }
  270. system("pause");
  271. break ;
  272.             case '3' :
  273. rewind (fp);
  274.                 another = 'Y' ;
  275.                 while (another == 'Y')
  276.                 {
  277. system("cls");
  278. printf("\n\n");
  279. printf("\t=== Update Employee's Records in the Database ===");
  280. printf("\n\n");
  281.                 printf("\tEnter Employee's ID Number: ");
  282.                     scanf("%s",&employee_id);
  283.                     printf("\n");
  284.                     rewind (fp) ;
  285.                     while (fread( &info, recsize, 1, fp ) == 1 )
  286.                     {
  287. if ( strcmp (info.emp_id, employee_id ) == 0 )
  288. {
  289. printf("\tEnter Employee's ID Number: ");
  290.                     scanf("%s",&info.emp_id);
  291.                     printf("\tEnter Employee's Name : ");
  292.                     fflush(stdin);
  293.                     gets(info.name);
  294.                     printf("\tEnter Gender M/F : ") ;
  295. info.sex = toupper(getche());
  296. printf("\n");
  297. printf("\tEnter Home Address: ");
  298. fflush(stdin);
  299.                     gets(info.address);
  300.                     printf("\tEnter Telephone Number: ");
  301. fflush(stdin);
  302.                     gets(info.telephone);
  303.                     printf("\tEnter Mobile Number: ");
  304. fflush(stdin);
  305.                     gets(info.mobile);
  306.                     printf("\tEnter Email Address: ");
  307.                     fflush(stdin);
  308.                     gets(info.email);
  309. printf("\n\n");
  310. printf("\tEmployee's records has been updated in the database.");
  311. printf("\n\n");
  312. system("pause");
  313.                     fseek ( fp, - recsize, SEEK_CUR ) ;
  314.                     fwrite ( &info, recsize, 1, fp ) ;
  315.                     break ;
  316. }
  317. }
  318.  if (strcmp(info.emp_id,employee_id) != 0 )
  319. {
  320. printf("\n\n");
  321. printf("\tNo Record in the Database.");
  322. printf("\n");
  323. system("pause");
  324. break;
  325. }
  326. printf("\n\n");
  327.                     printf ("\n\tUpdate Another Record (Y/N) : " ) ;
  328.                     fflush (stdin) ;
  329.                     another = toupper(getche());
  330.                 }
  331.                 break ;
  332.     case '4' :
  333. rewind (fp);
  334.                 another = 'Y' ;
  335.                 while ( another == 'Y' )
  336.                 {
  337.     system("cls");
  338.                     printf("\n\n");
  339. printf("\t=== Search Employee's Records in the Database ===");
  340. printf("\n\n");
  341.                 printf("\tEnter Employee's ID Number : ");
  342.                     scanf("%s",&employee_id);
  343.                 rewind (fp) ;
  344.                 printf("\n");
  345.                     while (fread( &info, recsize, 1, fp ) == 1 )
  346.                     {
  347.                         if (strcmp(info.emp_id,employee_id) == 0 )
  348.                         {
  349. printf("\n\tEmployee's ID Number : %s",info.emp_id);
  350.                 printf("\n\tEmployee's Name: %s",info.name);
  351.                     printf("\n\tGender: %c",info.sex);
  352.                     printf("\n\tHome Address : %s",info.address);
  353.                         printf("\n\tTelephone Number : %s",info.telephone);
  354.                     printf("\n\tMobile Number : %s",info.mobile);
  355.                     printf("\n\tEmail Address : %s",info.email);
  356. printf("\n\n");
  357. system("pause");
  358. break;
  359.         }
  360.                 }
  361. if (strcmp(info.emp_id,employee_id) != 0 )
  362. {
  363. printf("\n");
  364. printf("\tSorry No Record Found in the Database.");
  365. printf("\n\n");
  366. system("pause");
  367. break;
  368. }
  369. printf("\n");
  370.                     printf ("\n\tSearch Another Employee's Record? (Y/N) : " ) ;
  371.                     fflush (stdin) ;
  372.                     another = toupper(getche());
  373.                 }
  374.                 break ;
  375.             case '5' :
  376.                 another = 'Y' ;
  377.                 while ( another == 'Y' )
  378.                 {
  379.                     system("cls");
  380.                     flag=0;
  381.                     printf("\n\n");
  382. printf("\t=== Delete Employee's Records in the Database ===");
  383. printf("\n\n");
  384.                     printf("\tEnter Employee's ID Number : ");
  385.                     scanf("%s",&employee_id);
  386.                     printf("\n");
  387.                 ft = fopen ("TEMP.DAT", "wb") ;
  388.                     rewind (fp) ;
  389.                     while (fread (&info, recsize, 1, fp) == 1 )
  390.                     {
  391.                         if (strcmp(info.emp_id, employee_id) != 0 )
  392.                             fwrite(&info, recsize, 1, ft ) ;
  393.                         else
  394. flag=1;
  395.                     }
  396.                     fclose (fp) ;
  397.                     fclose (ft) ;
  398.                     remove ("RECORDS.DAT") ;
  399.                     rename ("TEMP.DAT", "RECORDS.DAT") ;
  400.                     fp = fopen ("RECORDS.DAT", "rb+") ;
  401.  if(flag==1) {
  402. printf("\n\n");
  403. printf("\tRecord Successfully Deleted From the Database.");
  404. printf("\n\n");
  405. system("pause");
  406. }
  407.                     else if (flag!=1) {
  408. printf("\n\n");
  409. printf("\tSorry Record Not Found in the Database.");
  410. printf("\n\n");
  411. system("pause");
  412. }
  413. printf("\n\n");
  414. printf( "\tDelete Another Employee's Record? (Y/N) " ) ;
  415. fflush ( stdin ) ;
  416. another = toupper(getche());
  417.                 }
  418.                 break ;
  419.             case '6' :
  420.                 fclose (fp) ;
  421.                 printf("\n\n");
  422.                 printf("\t\tThank You For Using This Program !!!");
  423.                 printf("\n\n");
  424.                 system("PAUSE");
  425.                 exit(0);
  426.         }
  427.     }
  428. } /* End of the Code */
  429.  
  430. http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=14012&lngWId=3
  431.  
  432. //**************************************
  433. // Name: Quicksort demo
  434. // Description:Quicksort demo
  435. // By: Mike Smith
  436. //**************************************
  437.  
  438. #include <stdio.h>
  439. #include <stdlib.h>
  440. #include <string.h>
  441. int lettercompare(const void *a, const void *b)
  442. {
  443.     const char* achar=(const char*)a;
  444.     const char* bchar=(const char*)b;
  445.     return *achar - *bchar;
  446. }
  447. int main(void)
  448. {
  449.     char sentence[80];
  450.     strcpy(sentence,"the quick brown fox jumped over the lazy dogs.");
  451.     int length=strlen(sentence);
  452.     qsort(sentence, length, 1, &lettercompare);
  453.     printf(sentence);
  454. }
  455.  
  456. http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=14010&lngWId=3
  457.  
  458. //**************************************
  459. // Name: Login Using a Text File in C
  460. // Description:While I'm writing my book on C programming I came across with the idea to include in my book topic on File Handling in C. The idea is to write a program using C as my programming language to store a username and password in a text file and create a login program that will ask the user to give the username and password. The program will search for the username and password that is already stored in our text file. In this example the name of the text file is users.txt. I
  461. If the username and password are correct and can be located in the text file the program will allow the user to access the system. But if username or password is incorrect the program will not allow the user to access the system. I hope you will find my work useful. Thank you.
  462. I am currently accepting programming work, it projects, school and application development.
  463. programming projects, thesis and capstone projects, IT consulting.
  464. work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
  465. My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
  466. My mobile number here in the Philippines is 09173084360.
  467. My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
  468. Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.
  469. My personal website is http://www.jakerpomperada.com
  470. // By: Jake R. Pomperada
  471. //**************************************
  472.  
  473. /* login.c
  474.  Author: Jake Rodriguez Pomperada,MAED-IT
  475.  Website: http://www.jakerpomperada.com
  476.  Emails: jakerpomperada@gmail.com and jakerpomperada@aol.com
  477.  Location : Bacolod City, Negros Occidental
  478.  Tool : Dev C++ Version 5.11
  479.  Date : January 7, 20193:46 PM Monday
  480. */
  481. #include <stdio.h>
  482. #include <conio.h>
  483. #include <stdlib.h>
  484. #include <string.h>
  485. void get_ID_and_PASS(char fileName[30],char *id,char *pass)
  486. {
  487. FILE *F = fopen(fileName,"r");
  488. if(F)
  489. {
  490. int count = 0;
  491. while(!feof(F))
  492. {
  493. char rawLine[50];
  494. fscanf(F,"%s",rawLine);
  495. if(!count++)
  496. strcpy(id,rawLine);
  497. else
  498. strcpy(pass,rawLine);
  499. }
  500. }else printf("Cannot open this file");
  501. fclose(F);
  502. }
  503. int main()
  504. {
  505. char fileName[30] = "users.txt";
  506. char userID[50],userPassW[50];
  507. char strID[50]="\0",strPASSW[50]="\0";
  508. char IDpref[50] = "user_id:\0",PASSWpref[50] = "password:\0";
  509. get_ID_and_PASS(fileName,userID,userPassW);
  510. char c;
  511. int pos = 0;
  512. printf("\n\n");
  513. printf("\tLOGIN SECURITY SYSTEM IN C USING TEXT FILES");
  514. printf("\n\n");
  515. printf("\tEnter User Name : ");
  516. scanf("%s",&strID);
  517. printf("\n");
  518. printf("\tEnter Your Password : ");
  519. do {
  520. c = getch();
  521. if( isprint(c) )
  522. {
  523. strPASSW[ pos++ ] = c;
  524. printf("%c", '*');
  525. }
  526. else if( c == 9 && pos )
  527. {
  528. strPASSW[pos--] = '\0';
  529. printf("%s", "\b \b");
  530. }
  531. } while( c != 13 );
  532. strcpy(strID,strcat(IDpref,strID));
  533. strcpy(strPASSW,strcat(PASSWpref,strPASSW));
  534. if (!strcmp(strID,userID)&&!strcmp(strPASSW,userPassW))
  535. {
  536. printf("\n\n");
  537. printf("\tCorrect Username And Password\n");
  538. printf("\n\n\tWelcome to the System\n\n");
  539. }
  540. else
  541. {
  542. printf("\n\n");
  543. printf("\tInvalid Username And Password. Try Again\n\n");
  544.  }
  545.  printf("\n\n");
  546.  printf("\tEND OF PROGRAM");
  547.  printf("\n\n");
  548.  system("pause");
  549. }
  550.  
  551. http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=14018&lngWId=3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement