473,809 Members | 2,826 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help in converting C++ to C

10 New Member
hi i am kind of new to programming, i have managed to create a simple payroll database in C++, but now i am trying to convert in into C but i am keep getting error, can anyone help me convert this code to C. I really need this so thatr i can learn my mistakes in C. Below is the C++ code that i have have developed.
Thank you,
Expand|Select|Wrap|Line Numbers
  1. #include<fstream>
  2. #include<string>
  3. #include<iostream>
  4. #include<iomanip>
  5. using namespace std;
  6. struct employee{ string fname, lname;
  7. double hourlyrate, hoursworked, netpay; }; //employee
  8. employee e[100];
  9. int n=0;
  10. void load(){
  11. ifstream fin("employee.txt",ios::in);
  12. while(fin>>e[n].fname>>e[n].lname>>e[n].hourlyrate>>e[n].hoursworked){
  13. e[n].netpay=e[n].hourlyrate*e[n].hoursworked;
  14. n++;}//WHILE
  15. }//LOAD
  16. void store(){
  17. ofstream fout("employee.txt",ios::out);
  18. for(int i=0; i<n; i++){
  19. if(e[i].fname!=" ")
  20. fout<<e[i].fname<<" "<<e[i].lname<<" "<<e[i].hourlyrate<<" "<<e[i].hoursworked<<endl;
  21. }//FOR
  22. }//STORE
  23.  
  24. void insert(){
  25. cout<<"Enter employee's first name: "; cin>>e[n].fname;
  26. cout<<"Enter employee's last name: "; cin>>e[n].lname;
  27. cout<<"Enter employee's salary per hour: "; cin>>e[n].hourlyrate;
  28. if(cin.fail())
  29. {cout<<"Error\n"; exit(1);}
  30. cout<<"Enter employee's hours worked: ";
  31. cin>>e[n].hoursworked;
  32. e[n].netpay=e[n].hourlyrate*e[n].hoursworked;
  33. n++; }//INSERTS THE RECORD TO ARRAY
  34.  
  35. void display(){
  36. cout<<setiosflags(ios::left)<<setw(15)<<"First Name"<<setw(15)<<"Last Name";
  37. cout<<setw(10)<<"Hourly Rate"<<setw(10)<<"HrsWorked"<<setw(10)<<"Net Pay";
  38. cout<<endl<<endl;
  39. cout<<setiosflags(ios::fixed|ios::showpoint|ios::left);
  40. for(int i=0;i<n;i++){
  41. if(e[i].fname!=" "){ 
  42. cout<<setiosflags(ios::left)<<setw(15)<<e[i].fname<<setw(15)<<e[i].lname;
  43. cout<<setprecision(2)<<setiosflags(ios::left)<<setw(10)<<e[i].hourlyrate;
  44. cout<<setw(10)<<e[i].hoursworked<<setw(10)<<e[i].netpay;
  45. cout<<resetiosflags(ios::left)<<endl;}//IF
  46. }//FOR
  47. }//THIS FUNCTION DISPLAYS ALL RECORDS IN ARRAY
  48.  
  49. int search(string s){
  50. for(int i=0;i<n;i++)if(s==e[i].lname)return i;//FOR
  51. return -1;
  52. }//SEARCH BY NAME,-1 NOT FOUND
  53.  
  54. void update(){
  55. string searchn;
  56. cout<<"Enter the Last Name of the Employee to be modified: "; cin>>searchn;
  57. int i=search(searchn); 
  58. if(i==-1) cout<<"EMPLOYEE NOT LISTED"<<endl;
  59. else{
  60. cout<<endl<<"Please enter the updated information."<<endl;
  61. cout<<"Enter employee's first name: "; cin>>e[i].fname;
  62. cout<<"Enter employee's last name: "; cin>>e[i].lname;
  63. cout<<"Enter employee's rate per hour: "; cin>>e[i].hourlyrate;
  64. cout<<"Enter employee's hours worked: "; cin>>e[i].hoursworked;
  65. e[i].netpay=(e[i].hourlyrate*e[i].hoursworked);}
  66. }//UPDATE
  67.  
  68. void deleterec(){
  69. string searchn;
  70. cout<<"Enter the Last Name of the Employee to delete: "; cin>>searchn;
  71. int k=-1;
  72. for(int j=0; j<n;j++){
  73. if(searchn==e[j].lname)
  74. k=j;}
  75. if(k!=-1)
  76. { cout<<" Name: "<<e[k].fname<<" "<<e[k].lname<<endl;
  77. cout<<" Salary: "<<e[k].hourlyrate<<endl;
  78. cout<<" Hrs Worked: "<<e[k].hoursworked<<endl;
  79. cout<<" Net Pay: "<<e[k].netpay<<endl<<endl;}
  80.  
  81. char ans;
  82. cout<<endl<<"Do you want to delete this record? (Y/N): ";
  83. cin>>ans;
  84. if(ans=='Y'||ans=='y'){
  85. e[k].fname=" ";}//IF
  86. else cout<<"EMPLOYEE NOT FOUND"; }//DELETE
  87.  
  88. void report(){
  89. int i=0;
  90. double totalhrs=0.00, totalpay=0.00;
  91. for(i=0;i<n;i++){
  92. totalhrs+=e[i].hoursworked;
  93. totalpay+=e[i].netpay; }//FOR
  94. cout<<"Total number of employees: " <<n<<endl<<endl;
  95. cout<<"Total hours worked by all employees: "<<totalhrs<<endl<<endl;
  96. cout<<"Total pay of all employees: "<<totalpay<<endl<<endl; }//REPORT
  97.  
  98. void deletefile(){
  99. int pword;
  100. cout<<"Enter your administrative password: "; cin>>pword;
  101. if(pword==0000){
  102. ofstream record("employee.txt", ios::out);
  103. record<<endl;
  104. load();
  105. record.close();}
  106. else cout<<"Wrong password entered."<<endl; }//DELETE FILE
  107.  
  108. void backupfile(){
  109. system("copy employee.txt backup.txt");
  110. cout<<endl<<"Back-up file has been made."<<endl;
  111. }//BACKUPFILE use cp command for UNIX
  112.  
  113. void main(){
  114. load();
  115. char choice='0';
  116. while (choice!='e'&&choice!='E'){
  117. cout<<endl<<"Payroll Database"<<endl;
  118. cout<<"1. Insert Employee Record and Compute Net Pay"<<endl;
  119. cout<<"2. Display All Records"<<endl;
  120. cout<<"3. Search Database"<<endl;
  121. cout<<"4. Update Record"<<endl;
  122. cout<<"5. Delete Record"<<endl;
  123. cout<<"6. Generate Report"<<endl;
  124. cout<<"7. Delete Database File"<<endl;
  125. cout<<"8. Back-up Database File"<<endl;
  126. cout<<endl<<" Type e to exit"<<endl<<endl;
  127. cout<<"Enter the number of your choice:";
  128. cin>>choice; cout<<endl;
  129. switch (choice){
  130. case '1': insert(); break;
  131. case '2': display(); break;
  132. case '3': char s[100]; int index;
  133. cout<<"Enter the last name of the person you want: ";
  134. cin>>s;
  135. index=search(s);
  136. if(index!=-1) {
  137. cout<<"Name: "<<e[index].fname<<" "<<e[index].lname<<endl;
  138. cout<<"Hourly Rate: "<<e[index].hourlyrate<<endl;
  139. cout<<"Hrs Worked: "<<e[index].hoursworked<<endl;
  140. cout<<"Net Pay: "<<e[index].netpay<<endl<<endl;}//IF
  141. else cout<<"EMPLOYEE NOT FOUND"<<endl;
  142. break;
  143. case '4': update(); break;
  144. case '5': deleterec(); break;
  145. case '6': report(); break;
  146. case '7': deletefile(); break;
  147. case '8': backupfile(); break;
  148. case 'e': store(); break; //EXIT
  149. default: cout<<"Invalid Choice"<<endl; break; }//SWITCH
  150. }//WHILE
  151. }//MAIN
Sep 25 '07
14 2450
RRick
463 Recognized Expert Contributor
The above fprintf format statement assumes that the last two values are integers. If they are doubles, use "%lf" instead of "%d".
Oct 1 '07 #11
optimum
10 New Member
Hi I am sorry for not updating my progress for the past 2 weeks, i have tried all those ideas given but i am having errors (almost 300), please someone help me translate the whole coding for me, i am feel very bad for requesting this, but i cant do it its really hard for me as i am still new, please someone help me i will need this to as a reference for my studies.
Oct 16 '07 #12
sicarie
4,677 Recognized Expert Moderator Specialist
Sorry dude, nobody here can (see our Posting Guidelines) or will (because it's your assignment) do your work for you. If you post the errors you are having trouble with, we can point you in the right direction. Or if you post a generic error, we can show you how to break it down (usually there is a line number around which the issue is - or something on that line caused the issue because it was instantiated/modified improperly, etc..), but we won't do it for you.

Also, cutting and pasting errors into Google usually will return someone who has had the same issue as you...
Oct 17 '07 #13
optimum
10 New Member
I have develop a new coding using C, with some problem where the search and update functions are working but when I enter a record which is not available it getting me to another record, my delete module also is notworking properly, and how to make my time tick. Below is my coding, thankyou for any help.

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<conio.h>
  4. #include<ctype.h>
  5. #include<string.h>
  6. #include <time.h>
  7. void ins(void);
  8. void oldf(void);
  9. void newf(void);
  10. void add(void);
  11. void search(void);
  12. void upd(void);
  13. void del(void);
  14. struct    payroll
  15.     { char no[5];
  16.       char name[25];
  17.       double salary;
  18.       double rate;
  19.       double net;
  20.       } payroll_rec;
  21.  
  22. void main()
  23. {
  24. char i;
  25. time_t now;
  26. time(&now);
  27.  
  28.  
  29. do
  30.   {
  31.     system("cls");
  32.  
  33.     printf("\n\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\7");
  34.     printf("\n\n Welcome to Optimum Technologies' Payroll Department\t\t\t\t\t  %.24s.\n",ctime(&now));
  35.     printf("\t\t   Main Menu\n\n");
  36.     printf("\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\n");
  37.     printf("\nWhat do you wish to do?\n");
  38.     printf("-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n\n");
  39.     printf("1. Insert Employee Record And Compute Weekly Pay\n");
  40.     printf("2. Display All Records\n");
  41.     printf("3. Compute Monthly Pay Slip\n");
  42.     printf("4. Add Employee Record\n");
  43.     printf("5. Search and View Record\n");
  44.     printf("6. Update Record\n");
  45.     printf("7. Delete Record\n");
  46.     printf("8. Exit\n");
  47.     printf("\n-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
  48.     printf("You choose number :");
  49.     i=getche();
  50.  
  51.       switch(tolower(i))
  52.         {
  53.          case '1': ins();  break;
  54.          case '2': oldf();  break;
  55.          case '3': newf();  break;
  56.          case '4': add();  break;
  57.          case '5': search();  break;
  58.          case '6': upd();  break;
  59.          case '7': del();  break;
  60.          case '8': printf("\7\n\tPlease any key to exit...");
  61.                   getch();
  62.                   exit(0);
  63.          break;
  64.          default : printf("\n\tChoice error !  Please try again.");
  65.          getch();
  66.         }
  67.   }while(i!='7');
  68.  
  69. }
  70.  
  71. void ins(void)
  72. {
  73. FILE *fp;
  74. if((fp=fopen("payroll.txt","wb"))==NULL)
  75.    {
  76.     printf("Error in opening file");
  77.      exit(1);
  78.    }
  79. struct payroll
  80. {
  81.   char no[5];
  82.   char name[25];
  83.   double salary;
  84.   double rate;
  85.   double net;
  86.   } payroll_rec;
  87. char numstr[50];
  88.  system("cls");
  89.  printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
  90.  printf("\n Insert Employee Record And Compute Weekly Pay Module\n");
  91.  printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3");
  92. do
  93.    {
  94.  
  95.      printf("\n\nEnter Employee No           : ");
  96.      gets(payroll_rec.no);
  97.      printf("Enter Employee Name         : ");
  98.      gets(payroll_rec.name);
  99.     printf("Enter Hours Worked Per Week : ");
  100.      payroll_rec.salary=atof(gets(numstr));
  101.      printf("Enter Hourly Wage           : ");
  102.      payroll_rec.rate=atof(gets(numstr));
  103.      payroll_rec.net=payroll_rec.salary*payroll_rec.rate;
  104.      printf("Your Weekly Pay is RM %.2f\n", payroll_rec.net);
  105.      fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
  106.      printf("Add another person(y/n)? :");
  107.    }
  108.    while(tolower(getche())=='y');
  109. fclose(fp);
  110. printf("\nPress any key to return to main menu");
  111. getch();
  112. }
  113.  
  114. void oldf(void)
  115. {
  116. FILE *fp;
  117. if((fp=fopen("payroll.txt","rb"))==NULL)
  118.     {
  119.      printf("Error in open file");
  120.      printf("\007");
  121.      getch();  exit(1);
  122.          } system("cls");
  123.  printf("\n \5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\7");
  124.  printf("\n\t\t\t Display Record Module\n ");
  125.  printf("\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\n\n");
  126.    printf("\n\n**********************************************************************\n");
  127.    printf(" Employee ID  Employee Name     Hours Worked   Hourly Wage   Weekly Pay\n");
  128.    printf("***********************************************************************\n");
  129.   while(fread(&payroll_rec,sizeof(payroll_rec),1,fp)==1)
  130.   {
  131.       printf(" %s\t\t%s\t\t%.2f\t%.2f\t\t%.2f\t\t\n",payroll_rec.no,payroll_rec.name,payroll_rec.salary,payroll_rec.rate,payroll_rec.net);
  132.  
  133.     }
  134. fclose(fp);
  135.  printf("Press any key to return to main menu\n");
  136. getch();
  137. }
  138.  
  139. void newf(void)
  140. {
  141. double net;
  142. double total;
  143. FILE *fp;
  144. if((fp=fopen("payroll.txt","rb"))==NULL)
  145.     {
  146.      printf("Error in open file");
  147.      printf("\007");
  148.      getch();  exit(1);
  149.     } system("cls");
  150.  printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
  151.  printf("\n\t\t   Compute Monthly Pay Slip Module\n");
  152.  printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n\n");
  153. while(fread(&payroll_rec,sizeof(payroll_rec),1,fp)==1)
  154.     {
  155.  
  156.     net=payroll_rec.salary*payroll_rec.rate*4;
  157.     total=payroll_rec.salary*4;
  158.     printf("\n\n||======================================================================||\n");
  159.     printf("||\t\t\tOptimum Technologies Pay Vaucher                ||\n");
  160.     printf("||                                                                      ||\n");
  161.     printf("||Employee Name : %s\t\t\t\t\t\t||\n",payroll_rec.name);
  162.     printf("||Empolyee ID   : %s\t\t\t\t\t\t\t||\n",payroll_rec.no);
  163.     printf("||Hours Worked  : %.2f\t\t\t\t\t\t\t||\n",total);
  164.     printf("||Hourly Wage   : RM %.2f\t\t\t\t\t\t\t||",payroll_rec.rate);
  165.     printf("||Net Salary    : RM %.2f\t\t\t\t\t\t||\n",net);
  166.     printf("||                                                                      ||\n");
  167.     printf("||This is a digitally signed voucher it does not require signature\t||\n");
  168.     printf("||                                                                      ||\n");
  169.     printf("||======================================================================||\n");
  170.   }
  171.   fclose(fp);
  172.   printf("Press any key to return to main menu");
  173.   getch();
  174. }
  175.  
  176. void add(void)
  177. {
  178. FILE *fp;
  179. if((fp=fopen("payroll.txt","ab"))==NULL)
  180.     {
  181.      printf("Error in open file");
  182.      printf("\007");
  183.      getch();  exit(1);
  184.     }
  185. char str[10];
  186.  system("cls");
  187.  printf("\n \5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\7");
  188.  printf("\n\t\t Add Record Module\n ");
  189.  printf("\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\n\n");
  190.   do{
  191.       printf("\nEnter Employee No :");
  192.       gets(payroll_rec.no);
  193.       printf("Enter Employee Name :");
  194.       gets(payroll_rec.name);
  195.       printf("Enter Hours Worked Per Week :");
  196.       payroll_rec.salary=atof(gets(str));
  197.       printf("Enter Hourly Wage:");
  198.       payroll_rec.rate=atof(gets(str));
  199.       payroll_rec.net=payroll_rec.salary*payroll_rec.rate;
  200.       printf("Your Weekly Pay is RM %.2f\n", payroll_rec.net);
  201.       fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
  202.       printf("Add another person(y/n)? :");
  203.      } while(tolower(getche())=='y');
  204. fclose(fp);
  205.  
  206. }
  207.  
  208.  
  209. void search(void)
  210. {
  211. FILE *fp;
  212. int i=0;
  213. int rec;
  214. char ch;
  215. int offset;
  216. system("cls");
  217. printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
  218.  printf("\n\t\t   Serach and View Record Module\n");
  219.  printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n\n");
  220.  
  221.   if((fp=fopen("payroll.txt","rb"))==NULL)
  222.     {
  223.      printf("\nError in open file");
  224.      printf("\007");
  225.      getch(); 
  226.      exit(1);
  227.     }
  228.  do
  229. {
  230.     printf("\n\nEnter record number to search :");
  231.     scanf("%d",&rec);  ch=getchar();
  232.     offset=(rec-1)*sizeof(payroll_rec);
  233.      if(fseek(fp,offset,0)!=0)
  234.      {
  235.       printf("Can't not find.\n");
  236.       getch(); 
  237.      exit(1);
  238.  
  239.      }
  240.      fread(&payroll_rec,sizeof(payroll_rec),1,fp);
  241.       printf("\nEmployee ID   : %s\n",payroll_rec.no);
  242.       printf("Employee Name : %s\n",payroll_rec.name);
  243.       printf("Hours Worked  : %.2f\n",payroll_rec.salary);
  244.       printf("Hourly Wage   : %.2f\n",payroll_rec.rate);
  245.       printf("Weekly Salary : %.2f\n",payroll_rec.net);
  246.       printf("Do you wish to continue(y/n)? :");
  247.  
  248.  
  249. }
  250.    while(tolower(getche())=='y');
  251. fclose(fp);
  252. printf("\nPress any key to return to main menu");
  253. getch();
  254. }    
  255.  
  256.  
  257. void upd(void)
  258. {
  259. FILE *fp;
  260. int i=0;
  261. int rec;
  262. char ch,str[20];
  263. char id[5];
  264. int offset;
  265. system("cls");
  266. printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
  267.  printf("\n\t\t   Update Record Module\n");
  268.  printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n\n");
  269.  
  270.   if((fp=fopen("payroll.txt","rb"))==NULL)
  271.     {
  272.      printf("\nError in open file");
  273.      printf("\007");
  274.      getch();  exit(1);
  275.     }
  276.  
  277.     printf("\nEnter record number :");
  278.     scanf("%d",&rec);  ch=getchar();
  279.     offset=(rec-1)*sizeof(payroll_rec);
  280.      if(fseek(fp,offset,0)!=0)
  281.      {
  282.       printf("Can't not find.\n");
  283.       getch();
  284.       exit(1);
  285.      }
  286.      fread(&payroll_rec,sizeof(payroll_rec),1,fp);
  287.     strcpy(id,payroll_rec.no);
  288.      getch();
  289.   fp=fopen("payroll.txt","r+b");
  290.   offset=(rec-1)*sizeof(payroll_rec);
  291.     if(fseek(fp,offset,0)!=0)
  292.     {
  293.      printf("Can't not find.\n");
  294.      getch();
  295.      exit(1);
  296.     }
  297.       printf("\nEnter Employee ID :%s\n",id);
  298.       strcpy(payroll_rec.no,id);
  299.      printf("Enter Employee Name :");
  300.      gets(payroll_rec.name);
  301.       printf("Enter Hours Worked :");
  302.       payroll_rec.salary=atof(gets(str));
  303.       printf("Enter Hourly Wage:");
  304.       payroll_rec.rate=atof(gets(str));
  305.       payroll_rec.net=payroll_rec.salary*payroll_rec.rate;
  306.       fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
  307.  
  308. fclose(fp);
  309. printf("Press any key to return to main menu");
  310. }
  311.  
  312. void del(void)
  313. {
  314. FILE*fp;
  315. int i=0;
  316. char ans;
  317. char rec[7];
  318. system("cls");
  319. printf("\n \5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\7");
  320. printf("\n\t\t Delete Record Module\n ");
  321. printf("\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\n\n");
  322. if((fp=fopen("payroll.txt","rb+"))==NULL)
  323. {
  324. printf("Error in open file");
  325. printf("\007");
  326. getch();
  327. exit(1);
  328. }
  329. printf("\n\nThis is data for delete\n");
  330. do{
  331. while(1){
  332. fread(&payroll_rec,sizeof(payroll_rec),1,fp);
  333. if(ferror(fp)){
  334.      printf("\nError read of delete file");
  335.      getch();  exit(1); }
  336.      if(feof(fp))
  337.      break;
  338.      ++i;
  339.      printf("%d. %s\t\t",i,payroll_rec.no);
  340.      }
  341.      printf("\nDo you want to delete data(y or n) :");
  342.      ans=getche();
  343.      if(ans=='y') {
  344.      printf("\nEnter record number :");
  345.      gets(rec);
  346.      fseek(fp,((atoi(rec)-1)*sizeof(payroll_rec)),SEEK_SET);
  347.      strcpy(payroll_rec.no,"\0");
  348.      strcpy(payroll_rec.name,"\0");
  349.      payroll_rec.salary=NULL;
  350.      payroll_rec.rate=NULL;
  351.      payroll_rec.net=NULL;
  352.      fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
  353.      if(ferror(fp)) {
  354.         printf("Error for delete data\n");
  355.         getch();
  356.         exit(1);
  357.         }
  358.         printf("Delete data complete\n");
  359.         }
  360.         printf("\nContinue(press c) or Exit(press e) :");
  361.         ans=getche();
  362.         printf("\n");
  363.         }while(ans!='e');
  364.         fclose(fp);
Oct 19 '07 #14
optimum
10 New Member
I have develop a new coding using C, with some problem where the search and update functions are working but when I enter a record which is not available it getting me to another record, my delete module also is notworking properly, and how to make my time tick. Below is my coding, thankyou for any help.

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<conio.h>
  4. #include<ctype.h>
  5. #include<string.h>
  6. #include <time.h>
  7. void ins(void);
  8. void oldf(void);
  9. void newf(void);
  10. void add(void);
  11. void search(void);
  12. void upd(void);
  13. void del(void);
  14. struct    payroll
  15.     { char no[5];
  16.       char name[25];
  17.       double salary;
  18.       double rate;
  19.       double net;
  20.       } payroll_rec;
  21.  
  22. void main()
  23. {
  24. char i;
  25. time_t now;
  26. time(&now);
  27.  
  28.  
  29. do
  30.   {
  31.     system("cls");
  32.  
  33.     printf("\n\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\7");
  34.     printf("\n\n Welcome to Optimum Technologies' Payroll Department\t\t\t\t\t  %.24s.\n",ctime(&now));
  35.     printf("\t\t   Main Menu\n\n");
  36.     printf("\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\n");
  37.     printf("\nWhat do you wish to do?\n");
  38.     printf("-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n\n");
  39.     printf("1. Insert Employee Record And Compute Weekly Pay\n");
  40.     printf("2. Display All Records\n");
  41.     printf("3. Compute Monthly Pay Slip\n");
  42.     printf("4. Add Employee Record\n");
  43.     printf("5. Search and View Record\n");
  44.     printf("6. Update Record\n");
  45.     printf("7. Delete Record\n");
  46.     printf("8. Exit\n");
  47.     printf("\n-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n");
  48.     printf("You choose number :");
  49.     i=getche();
  50.  
  51.       switch(tolower(i))
  52.         {
  53.          case '1': ins();  break;
  54.          case '2': oldf();  break;
  55.          case '3': newf();  break;
  56.          case '4': add();  break;
  57.          case '5': search();  break;
  58.          case '6': upd();  break;
  59.          case '7': del();  break;
  60.          case '8': printf("\7\n\tPlease any key to exit...");
  61.                   getch();
  62.                   exit(0);
  63.          break;
  64.          default : printf("\n\tChoice error !  Please try again.");
  65.          getch();
  66.         }
  67.   }while(i!='7');
  68.  
  69. }
  70.  
  71. void ins(void)
  72. {
  73. FILE *fp;
  74. if((fp=fopen("payroll.txt","wb"))==NULL)
  75.    {
  76.     printf("Error in opening file");
  77.      exit(1);
  78.    }
  79. struct payroll
  80. {
  81.   char no[5];
  82.   char name[25];
  83.   double salary;
  84.   double rate;
  85.   double net;
  86.   } payroll_rec;
  87. char numstr[50];
  88.  system("cls");
  89.  printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
  90.  printf("\n Insert Employee Record And Compute Weekly Pay Module\n");
  91.  printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3");
  92. do
  93.    {
  94.  
  95.      printf("\n\nEnter Employee No           : ");
  96.      gets(payroll_rec.no);
  97.      printf("Enter Employee Name         : ");
  98.      gets(payroll_rec.name);
  99.     printf("Enter Hours Worked Per Week : ");
  100.      payroll_rec.salary=atof(gets(numstr));
  101.      printf("Enter Hourly Wage           : ");
  102.      payroll_rec.rate=atof(gets(numstr));
  103.      payroll_rec.net=payroll_rec.salary*payroll_rec.rate;
  104.      printf("Your Weekly Pay is RM %.2f\n", payroll_rec.net);
  105.      fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
  106.      printf("Add another person(y/n)? :");
  107.    }
  108.    while(tolower(getche())=='y');
  109. fclose(fp);
  110. printf("\nPress any key to return to main menu");
  111. getch();
  112. }
  113.  
  114. void oldf(void)
  115. {
  116. FILE *fp;
  117. if((fp=fopen("payroll.txt","rb"))==NULL)
  118.     {
  119.      printf("Error in open file");
  120.      printf("\007");
  121.      getch();  exit(1);
  122.          } system("cls");
  123.  printf("\n \5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\7");
  124.  printf("\n\t\t\t Display Record Module\n ");
  125.  printf("\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\n\n");
  126.    printf("\n\n**********************************************************************\n");
  127.    printf(" Employee ID  Employee Name     Hours Worked   Hourly Wage   Weekly Pay\n");
  128.    printf("***********************************************************************\n");
  129.   while(fread(&payroll_rec,sizeof(payroll_rec),1,fp)==1)
  130.   {
  131.       printf(" %s\t\t%s\t\t%.2f\t%.2f\t\t%.2f\t\t\n",payroll_rec.no,payroll_rec.name,payroll_rec.salary,payroll_rec.rate,payroll_rec.net);
  132.  
  133.     }
  134. fclose(fp);
  135.  printf("Press any key to return to main menu\n");
  136. getch();
  137. }
  138.  
  139. void newf(void)
  140. {
  141. double net;
  142. double total;
  143. FILE *fp;
  144. if((fp=fopen("payroll.txt","rb"))==NULL)
  145.     {
  146.      printf("Error in open file");
  147.      printf("\007");
  148.      getch();  exit(1);
  149.     } system("cls");
  150.  printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
  151.  printf("\n\t\t   Compute Monthly Pay Slip Module\n");
  152.  printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n\n");
  153. while(fread(&payroll_rec,sizeof(payroll_rec),1,fp)==1)
  154.     {
  155.  
  156.     net=payroll_rec.salary*payroll_rec.rate*4;
  157.     total=payroll_rec.salary*4;
  158.     printf("\n\n||======================================================================||\n");
  159.     printf("||\t\t\tOptimum Technologies Pay Vaucher                ||\n");
  160.     printf("||                                                                      ||\n");
  161.     printf("||Employee Name : %s\t\t\t\t\t\t||\n",payroll_rec.name);
  162.     printf("||Empolyee ID   : %s\t\t\t\t\t\t\t||\n",payroll_rec.no);
  163.     printf("||Hours Worked  : %.2f\t\t\t\t\t\t\t||\n",total);
  164.     printf("||Hourly Wage   : RM %.2f\t\t\t\t\t\t\t||",payroll_rec.rate);
  165.     printf("||Net Salary    : RM %.2f\t\t\t\t\t\t||\n",net);
  166.     printf("||                                                                      ||\n");
  167.     printf("||This is a digitally signed voucher it does not require signature\t||\n");
  168.     printf("||                                                                      ||\n");
  169.     printf("||======================================================================||\n");
  170.   }
  171.   fclose(fp);
  172.   printf("Press any key to return to main menu");
  173.   getch();
  174. }
  175.  
  176. void add(void)
  177. {
  178. FILE *fp;
  179. if((fp=fopen("payroll.txt","ab"))==NULL)
  180.     {
  181.      printf("Error in open file");
  182.      printf("\007");
  183.      getch();  exit(1);
  184.     }
  185. char str[10];
  186.  system("cls");
  187.  printf("\n \5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\7");
  188.  printf("\n\t\t Add Record Module\n ");
  189.  printf("\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\n\n");
  190.   do{
  191.       printf("\nEnter Employee No :");
  192.       gets(payroll_rec.no);
  193.       printf("Enter Employee Name :");
  194.       gets(payroll_rec.name);
  195.       printf("Enter Hours Worked Per Week :");
  196.       payroll_rec.salary=atof(gets(str));
  197.       printf("Enter Hourly Wage:");
  198.       payroll_rec.rate=atof(gets(str));
  199.       payroll_rec.net=payroll_rec.salary*payroll_rec.rate;
  200.       printf("Your Weekly Pay is RM %.2f\n", payroll_rec.net);
  201.       fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
  202.       printf("Add another person(y/n)? :");
  203.      } while(tolower(getche())=='y');
  204. fclose(fp);
  205.  
  206. }
  207.  
  208.  
  209. void search(void)
  210. {
  211. FILE *fp;
  212. int i=0;
  213. int rec;
  214. char ch;
  215. int offset;
  216. system("cls");
  217. printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
  218.  printf("\n\t\t   Serach and View Record Module\n");
  219.  printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n\n");
  220.  
  221.   if((fp=fopen("payroll.txt","rb"))==NULL)
  222.     {
  223.      printf("\nError in open file");
  224.      printf("\007");
  225.      getch(); 
  226.      exit(1);
  227.     }
  228.  do
  229. {
  230.     printf("\n\nEnter record number to search :");
  231.     scanf("%d",&rec);  ch=getchar();
  232.     offset=(rec-1)*sizeof(payroll_rec);
  233.      if(fseek(fp,offset,0)!=0)
  234.      {
  235.       printf("Can't not find.\n");
  236.       getch(); 
  237.      exit(1);
  238.  
  239.      }
  240.      fread(&payroll_rec,sizeof(payroll_rec),1,fp);
  241.       printf("\nEmployee ID   : %s\n",payroll_rec.no);
  242.       printf("Employee Name : %s\n",payroll_rec.name);
  243.       printf("Hours Worked  : %.2f\n",payroll_rec.salary);
  244.       printf("Hourly Wage   : %.2f\n",payroll_rec.rate);
  245.       printf("Weekly Salary : %.2f\n",payroll_rec.net);
  246.       printf("Do you wish to continue(y/n)? :");
  247.  
  248.  
  249. }
  250.    while(tolower(getche())=='y');
  251. fclose(fp);
  252. printf("\nPress any key to return to main menu");
  253. getch();
  254. }    
  255.  
  256.  
  257. void upd(void)
  258. {
  259. FILE *fp;
  260. int i=0;
  261. int rec;
  262. char ch,str[20];
  263. char id[5];
  264. int offset;
  265. system("cls");
  266. printf("\n\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7");
  267.  printf("\n\t\t   Update Record Module\n");
  268.  printf("\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\n\n");
  269.  
  270.   if((fp=fopen("payroll.txt","rb"))==NULL)
  271.     {
  272.      printf("\nError in open file");
  273.      printf("\007");
  274.      getch();  exit(1);
  275.     }
  276.  
  277.     printf("\nEnter record number :");
  278.     scanf("%d",&rec);  ch=getchar();
  279.     offset=(rec-1)*sizeof(payroll_rec);
  280.      if(fseek(fp,offset,0)!=0)
  281.      {
  282.       printf("Can't not find.\n");
  283.       getch();
  284.       exit(1);
  285.      }
  286.      fread(&payroll_rec,sizeof(payroll_rec),1,fp);
  287.     strcpy(id,payroll_rec.no);
  288.      getch();
  289.   fp=fopen("payroll.txt","r+b");
  290.   offset=(rec-1)*sizeof(payroll_rec);
  291.     if(fseek(fp,offset,0)!=0)
  292.     {
  293.      printf("Can't not find.\n");
  294.      getch();
  295.      exit(1);
  296.     }
  297.       printf("\nEnter Employee ID :%s\n",id);
  298.       strcpy(payroll_rec.no,id);
  299.      printf("Enter Employee Name :");
  300.      gets(payroll_rec.name);
  301.       printf("Enter Hours Worked :");
  302.       payroll_rec.salary=atof(gets(str));
  303.       printf("Enter Hourly Wage:");
  304.       payroll_rec.rate=atof(gets(str));
  305.       payroll_rec.net=payroll_rec.salary*payroll_rec.rate;
  306.       fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
  307.  
  308. fclose(fp);
  309. printf("Press any key to return to main menu");
  310. }
  311.  
  312. void del(void)
  313. {
  314. FILE*fp;
  315. int i=0;
  316. char ans;
  317. char rec[7];
  318. system("cls");
  319. printf("\n \5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\7");
  320. printf("\n\t\t Delete Record Module\n ");
  321. printf("\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\5\n\n");
  322. if((fp=fopen("payroll.txt","rb+"))==NULL)
  323. {
  324. printf("Error in open file");
  325. printf("\007");
  326. getch();
  327. exit(1);
  328. }
  329. printf("\n\nThis is data for delete\n");
  330. do{
  331. while(1){
  332. fread(&payroll_rec,sizeof(payroll_rec),1,fp);
  333. if(ferror(fp)){
  334.      printf("\nError read of delete file");
  335.      getch();  exit(1); }
  336.      if(feof(fp))
  337.      break;
  338.      ++i;
  339.      printf("%d. %s\t\t",i,payroll_rec.no);
  340.      }
  341.      printf("\nDo you want to delete data(y or n) :");
  342.      ans=getche();
  343.      if(ans=='y') {
  344.      printf("\nEnter record number :");
  345.      gets(rec);
  346.      fseek(fp,((atoi(rec)-1)*sizeof(payroll_rec)),SEEK_SET);
  347.      strcpy(payroll_rec.no,"\0");
  348.      strcpy(payroll_rec.name,"\0");
  349.      payroll_rec.salary=NULL;
  350.      payroll_rec.rate=NULL;
  351.      payroll_rec.net=NULL;
  352.      fwrite(&payroll_rec,sizeof(payroll_rec),1,fp);
  353.      if(ferror(fp)) {
  354.         printf("Error for delete data\n");
  355.         getch();
  356.         exit(1);
  357.         }
  358.         printf("Delete data complete\n");
  359.         }
  360.         printf("\nContinue(press c) or Exit(press e) :");
  361.         ans=getche();
  362.         printf("\n");
  363.         }while(ans!='e');
  364.         fclose(fp);
  365.         }
Oct 19 '07 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

6
3199
by: Newbee Adam | last post by:
I have been reading in help how I need to use decimal becuase currency does not exist like I used in vb6. I had a difficult time on google and msdn finding how or if I can take the value of text box as decimal or do I just have to make another decimal variable .. So I took a guess hoping CDec would come up blue if I type it in with no squigglies on the line. But is this actually converting it to decimal. Next if so, I do not like the...
2
1445
by: Megat | last post by:
I'm trying to create a conversion program, that convert a simple proprietry programming language to an international standard languange, using Visual C++. Need some help from those who has experience or anyone who has any idea in creating such program. Really appreciate your help. Thank you
8
5746
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple output html files. The problem is while reading through the worddoc paragraph,the special characters are not identified. So in the xml file,it's just storing that as "?".So I couldn't able to retrive the characters in my ouput html files.
4
2961
by: Jake Jessup | last post by:
A client wants me to do a conversion from Access 2.0 (yeah, I know, unreal). The problem is, she doesn't have the install disks and I haven't had a copy of 2.0 in years. If some kind should could kindly point me to a place where I might get a copy, I would be grateful. I'm willing to do a trade for it.
5
2529
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant applications. I am testing an upgrade of all of the sites and have converted the main root site...although not necessarily fixed any issues. I move on instead and converted one of the virtual roots that is a seperate
27
1985
by: sam_cit | last post by:
Hi, I needed help in converting a character to the correspoding hexadecimal values, like the following example, ASCII value : ABC Hex Code Value : %41%42%43... whats the logic of conversion...
16
5451
by: manmit.walia | last post by:
Hello All, I have tried multiple online tools to convert an VB6 (bas) file to VB.NET file and no luck. I was hoping that someone could help me covert this. I am new to the .NET world and still learning all help would be greatly apperciated. Attribute VB_Name = "Module1" Option Explicit
2
2230
Mhel
by: Mhel | last post by:
Hi everyone! I need some help in Converting Infix to postfix.I need a program that would do it. Please, I really need help.
10
3247
by: Hank Stalica | last post by:
I'm having this weird problem where my code does the following conversion from string to float: 27000000.0 -27000000.00 2973999.99 -29740000.00 2989999.13 -2989999.25 The number on the left is the string I get after tokenizing a bigger string. The number on the right is the number I get after the conversion.
7
5342
helpwithcode
by: helpwithcode | last post by:
Hi people, I am just learning java.I have been creating a project which involves JDBC Connectivity.I find that the statements, String string_dob=text_dob.getText(); //Converting string to date System.out.println(string_dob); s.Info_DOB=Date.valueOf(string_dob); runs perfectly fine in the method insert() and throws up an illegal Exception in the method UPDATE.This is the error I get when I pass a date "1979-05-02"
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10633
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10114
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.