Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CSS Radial Gradient;
- background: radial-gradient(#e66465, #9198e5);
- background: radial-gradient(closest-side, #3f87a6, #ebf8e1, #f69d3c);
- background: radial-gradient(circle at 100%, #333, #333 50%, #eee 75%, #333 75%);
- background: radial-gradient(ellipse at top, #e66465, transparent),
- radial-gradient(ellipse at bottom, #4d9f0c, transparent);
- http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=138&lngWId=14
- //**************************************
- // Name: Login Using a Text File in C
- // 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
- 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.
- I am currently accepting programming work, it projects, school and application development.
- programming projects, thesis and capstone projects, IT consulting.
- 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.
- My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
- My mobile number here in the Philippines is 09173084360.
- My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
- Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.
- My personal website is http://www.jakerpomperada.com
- // By: Jake R. Pomperada
- //**************************************
- /* login.c
- Author: Jake Rodriguez Pomperada,MAED-IT
- Website: http://www.jakerpomperada.com
- Emails: jakerpomperada@gmail.com and jakerpomperada@aol.com
- Location : Bacolod City, Negros Occidental
- Tool : Dev C++ Version 5.11
- Date : January 7, 20193:46 PM Monday
- */
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- #include <string.h>
- void get_ID_and_PASS(char fileName[30],char *id,char *pass)
- {
- FILE *F = fopen(fileName,"r");
- if(F)
- {
- int count = 0;
- while(!feof(F))
- {
- char rawLine[50];
- fscanf(F,"%s",rawLine);
- if(!count++)
- strcpy(id,rawLine);
- else
- strcpy(pass,rawLine);
- }
- }else printf("Cannot open this file");
- fclose(F);
- }
- int main()
- {
- char fileName[30] = "users.txt";
- char userID[50],userPassW[50];
- char strID[50]="\0",strPASSW[50]="\0";
- char IDpref[50] = "user_id:\0",PASSWpref[50] = "password:\0";
- get_ID_and_PASS(fileName,userID,userPassW);
- char c;
- int pos = 0;
- printf("\n\n");
- printf("\tLOGIN SECURITY SYSTEM IN C USING TEXT FILES");
- printf("\n\n");
- printf("\tEnter User Name : ");
- scanf("%s",&strID);
- printf("\n");
- printf("\tEnter Your Password : ");
- do {
- c = getch();
- if( isprint(c) )
- {
- strPASSW[ pos++ ] = c;
- printf("%c", '*');
- }
- else if( c == 9 && pos )
- {
- strPASSW[pos--] = '\0';
- printf("%s", "\b \b");
- }
- } while( c != 13 );
- strcpy(strID,strcat(IDpref,strID));
- strcpy(strPASSW,strcat(PASSWpref,strPASSW));
- if (!strcmp(strID,userID)&&!strcmp(strPASSW,userPassW))
- {
- printf("\n\n");
- printf("\tCorrect Username And Password\n");
- printf("\n\n\tWelcome to the System\n\n");
- }
- else
- {
- printf("\n\n");
- printf("\tInvalid Username And Password. Try Again\n\n");
- }
- printf("\n\n");
- printf("\tEND OF PROGRAM");
- printf("\n\n");
- system("pause");
- }
- http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=14018&lngWId=3
- //**************************************
- // Name: Binary read
- // Description:This code takes a string of ones and zeros and converts them into an integer.
- // By: Mike Smith
- //**************************************
- #include <cstdio>
- #include <iostream>
- #include <string>
- using namespace std;
- int binaryToInt(string binary)
- {
- int number = 0;
- for(unsigned char c: binary)
- {
- number<<=1;
- number|=c-'0';
- }
- return number;
- }
- int main (void)
- {
- string binary = "101";
- int number = binaryToInt(binary);
- cout << binary << " is " << number << endl;
- }
- http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=14016&lngWId=3
- //**************************************
- // Name: EMPLOYEES CONTACT DETAILS SYSTEM IN C
- // 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.
- I am currently accepting programming work, it projects, school
- programming projects, thesis and capstone projects, IT consulting
- 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.
- My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
- My mobile number here in the Philippines is 09173084360.
- My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
- My personal website is http://www.jakerpomperada.com
- // By: Jake R. Pomperada
- //**************************************
- /*employees_details.c
- Authors: Jake R. Pomperada,MAED-IT
- Emails: jakerpomperada@gmail.com
- Tool : Dev C++ Version 5.11
- Date : December 24, 2018 Monday 11:46 PM
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- #include <ctype.h>
- #include <string.h>
- main( )
- {
- FILE *fp, *ft ;
- char another, choice ;
- struct employees
- {
- char emp_id[200];
- char name[200];
- char sex;
- char address[200];
- char telephone[200];
- char mobile[200];
- char email[200];
- };
- struct employees info ;
- char employee_id[200];
- int flag=0;
- long int recsize ;
- fp = fopen ("RECORDS.DAT", "rb+" ) ;
- if ( fp == NULL )
- {
- fp = fopen ("RECORDS.DAT", "wb+" ) ;
- if ( fp == NULL )
- {
- puts ("Cannot open file" ) ;
- exit(0) ;
- }
- }
- recsize = sizeof ( info ) ;
- while (1)
- {
- system("CLS");
- printf("\n");
- printf("\n\t===========================================");
- printf("\n\t\tEMPLOYEES CONTACT DETAILS SYSTEM ");
- printf("\n\t\t\tCreated By");
- printf("\n\tJake R. Pomperada and Kristine T. Soberano");
- printf("\n\t===========================================");
- printf("\n\n");
- printf ( "\t1. ADD EMPLOYEE'S RECORD") ;
- printf("\n");
- printf ( "\t2. DISPLAY EMPLOYEE'S RECORD" ) ;
- printf("\n");
- printf ( "\t3. UPDATE EMPLOYEE'S RECORD" ) ;
- printf("\n");
- printf ( "\t4. SEARCH EMPLOYEE'S RECORD" ) ;
- printf("\n");
- printf ( "\t5. DELETE EMPLOYEE'S RECORD" ) ;
- printf("\n");
- printf ( "\t6. QUIT PROGRAM" );
- printf("\n\n\n");
- printf ("\tSELECT YOUR CHOICE : ") ;
- fflush (stdin) ;
- choice = getche() ;
- switch (choice)
- {
- case '1' :
- fseek (fp, 0 ,SEEK_END) ;
- another = 'Y' ;
- while ( another == 'Y' )
- {
- system("cls");
- printf("\n\n");
- printf("\t=== Add New Employee's Record in the Database ===");
- printf("\n\n");
- printf("\tEnter Employees ID Number: ");
- scanf("%s",&info.emp_id);
- printf("\tEnter Employee's Name: ");
- fflush(stdin);
- gets(info.name);
- printf("\tEnter Gender M/F : ") ;
- info.sex = toupper(getche());
- printf("\n");
- printf("\tEnter Home Address: ");
- fflush(stdin);
- gets(info.address);
- printf("\tEnter Telephone Number: ");
- fflush(stdin);
- gets(info.telephone);
- printf("\tEnter Mobile Number : ");
- fflush(stdin);
- gets(info.mobile);
- printf("\tEnter Email Address : ");
- fflush(stdin);
- gets(info.email);
- fwrite (&info, recsize, 1, fp ) ;
- printf("\n\n");
- printf ("\n\tAdd another Record (Y/N) : ") ;
- fflush (stdin) ;
- another = toupper(getche()) ;
- }
- break ;
- case '2' :
- system("cls");
- rewind (fp);
- printf("\n\n");
- printf("\t=== View Employee's Records in the Database ===");
- printf("\n");
- while ( fread ( &info, recsize, 1, fp ) == 1 )
- {
- printf("\n\tEmployee's ID Number : %s",info.emp_id);
- printf("\n\tEmployee's Name: %s",info.name);
- printf("\n\tGender: %c",info.sex);
- printf("\n\tHome Address : %s",info.address);
- printf("\n\tTelephone Number : %s",info.telephone);
- printf("\n\tMobile Number : %s",info.mobile);
- printf("\n\tEmail Address : %s",info.email);
- printf("\n\n");
- }
- system("pause");
- break ;
- case '3' :
- rewind (fp);
- another = 'Y' ;
- while (another == 'Y')
- {
- system("cls");
- printf("\n\n");
- printf("\t=== Update Employee's Records in the Database ===");
- printf("\n\n");
- printf("\tEnter Employee's ID Number: ");
- scanf("%s",&employee_id);
- printf("\n");
- rewind (fp) ;
- while (fread( &info, recsize, 1, fp ) == 1 )
- {
- if ( strcmp (info.emp_id, employee_id ) == 0 )
- {
- printf("\tEnter Employee's ID Number: ");
- scanf("%s",&info.emp_id);
- printf("\tEnter Employee's Name : ");
- fflush(stdin);
- gets(info.name);
- printf("\tEnter Gender M/F : ") ;
- info.sex = toupper(getche());
- printf("\n");
- printf("\tEnter Home Address: ");
- fflush(stdin);
- gets(info.address);
- printf("\tEnter Telephone Number: ");
- fflush(stdin);
- gets(info.telephone);
- printf("\tEnter Mobile Number: ");
- fflush(stdin);
- gets(info.mobile);
- printf("\tEnter Email Address: ");
- fflush(stdin);
- gets(info.email);
- printf("\n\n");
- printf("\tEmployee's records has been updated in the database.");
- printf("\n\n");
- system("pause");
- fseek ( fp, - recsize, SEEK_CUR ) ;
- fwrite ( &info, recsize, 1, fp ) ;
- break ;
- }
- }
- if (strcmp(info.emp_id,employee_id) != 0 )
- {
- printf("\n\n");
- printf("\tNo Record in the Database.");
- printf("\n");
- system("pause");
- break;
- }
- printf("\n\n");
- printf ("\n\tUpdate Another Record (Y/N) : " ) ;
- fflush (stdin) ;
- another = toupper(getche());
- }
- break ;
- case '4' :
- rewind (fp);
- another = 'Y' ;
- while ( another == 'Y' )
- {
- system("cls");
- printf("\n\n");
- printf("\t=== Search Employee's Records in the Database ===");
- printf("\n\n");
- printf("\tEnter Employee's ID Number : ");
- scanf("%s",&employee_id);
- rewind (fp) ;
- printf("\n");
- while (fread( &info, recsize, 1, fp ) == 1 )
- {
- if (strcmp(info.emp_id,employee_id) == 0 )
- {
- printf("\n\tEmployee's ID Number : %s",info.emp_id);
- printf("\n\tEmployee's Name: %s",info.name);
- printf("\n\tGender: %c",info.sex);
- printf("\n\tHome Address : %s",info.address);
- printf("\n\tTelephone Number : %s",info.telephone);
- printf("\n\tMobile Number : %s",info.mobile);
- printf("\n\tEmail Address : %s",info.email);
- printf("\n\n");
- system("pause");
- break;
- }
- }
- if (strcmp(info.emp_id,employee_id) != 0 )
- {
- printf("\n");
- printf("\tSorry No Record Found in the Database.");
- printf("\n\n");
- system("pause");
- break;
- }
- printf("\n");
- printf ("\n\tSearch Another Employee's Record? (Y/N) : " ) ;
- fflush (stdin) ;
- another = toupper(getche());
- }
- break ;
- case '5' :
- another = 'Y' ;
- while ( another == 'Y' )
- {
- system("cls");
- flag=0;
- printf("\n\n");
- printf("\t=== Delete Employee's Records in the Database ===");
- printf("\n\n");
- printf("\tEnter Employee's ID Number : ");
- scanf("%s",&employee_id);
- printf("\n");
- ft = fopen ("TEMP.DAT", "wb") ;
- rewind (fp) ;
- while (fread (&info, recsize, 1, fp) == 1 )
- {
- if (strcmp(info.emp_id, employee_id) != 0 )
- fwrite(&info, recsize, 1, ft ) ;
- else
- flag=1;
- }
- fclose (fp) ;
- fclose (ft) ;
- remove ("RECORDS.DAT") ;
- rename ("TEMP.DAT", "RECORDS.DAT") ;
- fp = fopen ("RECORDS.DAT", "rb+") ;
- if(flag==1) {
- printf("\n\n");
- printf("\tRecord Successfully Deleted From the Database.");
- printf("\n\n");
- system("pause");
- }
- else if (flag!=1) {
- printf("\n\n");
- printf("\tSorry Record Not Found in the Database.");
- printf("\n\n");
- system("pause");
- }
- printf("\n\n");
- printf( "\tDelete Another Employee's Record? (Y/N) " ) ;
- fflush ( stdin ) ;
- another = toupper(getche());
- }
- break ;
- case '6' :
- fclose (fp) ;
- printf("\n\n");
- printf("\t\tThank You For Using This Program !!!");
- printf("\n\n");
- system("PAUSE");
- exit(0);
- }
- }
- } /* End of the Code */
- http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=14012&lngWId=3
- //**************************************
- // Name: Quicksort demo
- // Description:Quicksort demo
- // By: Mike Smith
- //**************************************
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int lettercompare(const void *a, const void *b)
- {
- const char* achar=(const char*)a;
- const char* bchar=(const char*)b;
- return *achar - *bchar;
- }
- int main(void)
- {
- char sentence[80];
- strcpy(sentence,"the quick brown fox jumped over the lazy dogs.");
- int length=strlen(sentence);
- qsort(sentence, length, 1, &lettercompare);
- printf(sentence);
- }
- http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=14010&lngWId=3
- //**************************************
- // Name: Login Using a Text File in C
- // 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
- 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.
- I am currently accepting programming work, it projects, school and application development.
- programming projects, thesis and capstone projects, IT consulting.
- 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.
- My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
- My mobile number here in the Philippines is 09173084360.
- My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
- Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.
- My personal website is http://www.jakerpomperada.com
- // By: Jake R. Pomperada
- //**************************************
- /* login.c
- Author: Jake Rodriguez Pomperada,MAED-IT
- Website: http://www.jakerpomperada.com
- Emails: jakerpomperada@gmail.com and jakerpomperada@aol.com
- Location : Bacolod City, Negros Occidental
- Tool : Dev C++ Version 5.11
- Date : January 7, 20193:46 PM Monday
- */
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- #include <string.h>
- void get_ID_and_PASS(char fileName[30],char *id,char *pass)
- {
- FILE *F = fopen(fileName,"r");
- if(F)
- {
- int count = 0;
- while(!feof(F))
- {
- char rawLine[50];
- fscanf(F,"%s",rawLine);
- if(!count++)
- strcpy(id,rawLine);
- else
- strcpy(pass,rawLine);
- }
- }else printf("Cannot open this file");
- fclose(F);
- }
- int main()
- {
- char fileName[30] = "users.txt";
- char userID[50],userPassW[50];
- char strID[50]="\0",strPASSW[50]="\0";
- char IDpref[50] = "user_id:\0",PASSWpref[50] = "password:\0";
- get_ID_and_PASS(fileName,userID,userPassW);
- char c;
- int pos = 0;
- printf("\n\n");
- printf("\tLOGIN SECURITY SYSTEM IN C USING TEXT FILES");
- printf("\n\n");
- printf("\tEnter User Name : ");
- scanf("%s",&strID);
- printf("\n");
- printf("\tEnter Your Password : ");
- do {
- c = getch();
- if( isprint(c) )
- {
- strPASSW[ pos++ ] = c;
- printf("%c", '*');
- }
- else if( c == 9 && pos )
- {
- strPASSW[pos--] = '\0';
- printf("%s", "\b \b");
- }
- } while( c != 13 );
- strcpy(strID,strcat(IDpref,strID));
- strcpy(strPASSW,strcat(PASSWpref,strPASSW));
- if (!strcmp(strID,userID)&&!strcmp(strPASSW,userPassW))
- {
- printf("\n\n");
- printf("\tCorrect Username And Password\n");
- printf("\n\n\tWelcome to the System\n\n");
- }
- else
- {
- printf("\n\n");
- printf("\tInvalid Username And Password. Try Again\n\n");
- }
- printf("\n\n");
- printf("\tEND OF PROGRAM");
- printf("\n\n");
- system("pause");
- }
- http://planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=14018&lngWId=3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement