473,503 Members | 3,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you write a function with integers used outside without using globals?

8 New Member
I've been trying to get this, but no matter what method I try, nothing works and the book shows only the most simplistic examples. I have other functions currently that run, but with global values. I want to fix it all, but to do that, I need to get the following function to work:

function prototype:
int ToTaling(int &,int &,int &,int &,int &,int &,int &,int &,int &);
(OR)
//int &TotalRate, int &TotalRegHours, int &TotalOvtHours, int &TotalGrossPay,
// int &TotalFedTax, int &TotalStateTax, int &TotalSSITax, int &TotalDeferred,
// int &TotalNet);
(I tried it with the actual names, I tried it with * instead of ampersand, what am I missing here? I've also tried void at the beginning. Nothing seems to work.)

(inside main)
int TotalRate, TotalRegHours, TotalOvtHours, TotalGrossPay, TotalFedTax,
TotalStateTax,TotalSSITax, TotalDeferred,TotalNet;

ToTaling(&TotalRate,&TotalRegHours,&TotalOvtHours, &TotalGrossPay,
&TotalFedTax,&TotalStateTax,&TotalSSITax,&TotalDef erred,
&TotalNet);


And then the function outside the main:
{
int J = 0;
while (J<=H){
TotalRate=TotalRate+Payrate[J]; // equals Total += Hours[J+1];
TotalRegHours=TotalRegHours+RegHours[J]; // equals Total += Hours[J+1];
TotalOvtHours=TotalOvtHours+OvtHours[J];
TotalGrossPay=TotalGrossPay+CalcGross[J];
TotalFedTax=TotalFedTax+calcFed[J];
TotalStateTax=TotalStateTax+calcState[J];
TotalSSITax=TotalSSITax+calcSSi[J];
TotalDeferred=TotalDeferred+Deferred[J];
TotalNet=TotalNet+NetPay[J]; // equals Total += Hours[J+1];
J=J+1;
}

return (TotalRate, TotalRegHours, TotalOvtHours, TotalGrossPay, TotalFedTax,TotalStateTax, TotalSSITax, TotalDeferred, TotalNet);
}

The current error I'm getting is : cannot convert parameter 1 from 'int *' to 'int &' ....
The following line:
&TotalNet); (in the main, though probably the entire thing!)

Thanks for any and all help!
Nov 15 '09 #1
13 2034
JonathanS
37 New Member
Expand|Select|Wrap|Line Numbers
  1. ToTaling(&TotalRate,&TotalRegHours,&TotalOvtHours, &TotalGrossPay,
  2. &TotalFedTax,&TotalStateTax,&TotalSSITax,&TotalDef erred,
  3. &TotalNet);
  4.  
Should not use the ampersands when you call it in main. Also, you don't need to have a return statement if you're passing/returning things by reference, so your function can have the return type void.

I know they're boring but reread those simple examples and see if you can tell what exactly is happening in memory (what are the references referencing)
Nov 15 '09 #2
lordhoban
8 New Member
I got the function running, thanks to your very on target advice. Now the issue is the output. -107374160 --It's giving me these values in return instead of the actual number.

Do I need a special character to reference back to it when printing the value to a file?

I tried going back to the examples and they're very unhelpful. A few little helpful hints from you and I'm actually getting somewhere...
Nov 15 '09 #3
RRick
463 Recognized Expert Contributor
The return value for Taling looks bad
return (TotalRate, TotalRegHours, TotalOvtHours, TotalGrossPay, TotalFedTax,TotalStateTax, TotalSSITax, TotalDeferred, TotalNet);
I'm not sure how to read this return value into an array or separate variables.

Also, it looks like you don't need to have ToTaling return anything because the parameters are passed by reference, and their values are changed directly by the subroutine.
Nov 15 '09 #4
JonathanS
37 New Member
Run your code through a good debugger and find out where the value is getting scrambled. Did you leave in one of the ampersands when you call your function in main? If you're not comfortable with the debugger pepper your code with cout statements to trace it. I can't begin to know where that value comes from but it's most likely an address or possibly due to an overflow.
Nov 15 '09 #5
Banfa
9,065 Recognized Expert Moderator Expert
@lordhoban
It may be useful to post the code you are using to output the values as well. For instance if you have more misplaced & you will be getting the wrong values because you will be getting the memory addresses of the integers not the integers themselves.
Nov 15 '09 #6
lordhoban
8 New Member
Updated Code (all the code relevant to the problem at hand. I don't have any errors, but I do have warnings about converting float to int. Could that be causing it?):
Prototype:
Expand|Select|Wrap|Line Numbers
  1. void ToTaling(int &,int &,int &,int &,int &,int &,int &,int &,int &);
  2.  
  3. #define REPORTFORMAT7 "Totals \n"
  4. #define REPORTFORMAT5 "                %3.2d%11.2d %13.2d %9.2d %11.2d%10.2d\n"
  5. #define REPORTFORMAT6 "                          %4.2d%24.2d %11.2d\n"
  6.  
  7.  
  8. Main body:
  9. int TotalRate, TotalRegHours, TotalOvtHours, TotalGrossPay, TotalFedTax,
  10.     TotalStateTax,TotalSSITax, TotalDeferred,TotalNet;
  11.  
  12. ToTaling(TotalRate,TotalRegHours,TotalOvtHours,TotalGrossPay,
  13. TotalFedTax,TotalStateTax,TotalSSITax,TotalDeferred, TotalNet);
  14.  
  15. fprintf(reportFile,REPORTFORMAT7);
  16. fprintf (reportFile,REPORTFORMAT, TotalRate,TotalRegHours,TotalGrossPay, TotalFedTax,TotalSSITax,TotalNet); 
  17. fprintf(reportFile,REPORTFORMAT ,TotalOvtHours,TotalStateTax,TotalDeferred);
  18.  
  19. AND ACTUAL function:
  20. void ToTaling(int &TotalRate, int &TotalRegHours, int &TotalOvtHours, int &TotalGrossPay,
  21.  int &TotalFedTax, int &TotalStateTax, int &TotalSSITax, int &TotalDeferred,
  22.  int &TotalNet)
  23. {
  24.     int J = 0;
  25.     while (J<=H){
  26.     TotalRate=TotalRate+Payrate[J]; // equals Total += Hours[J+1];
  27.     TotalRegHours=TotalRegHours+RegHours[J]; // equals Total += Hours[J+1];
  28.     TotalOvtHours=TotalOvtHours+OvtHours[J]; 
  29.     TotalGrossPay=TotalGrossPay+CalcGross[J]; 
  30.     TotalFedTax=TotalFedTax+calcFed[J]; 
  31.     TotalStateTax=TotalStateTax+calcState[J]; 
  32.     TotalSSITax=TotalSSITax+calcSSi[J]; 
  33.     TotalDeferred=TotalDeferred+Deferred[J]; 
  34.     TotalNet=TotalNet+NetPay[J]; // equals Total += Hours[J+1];
  35.     J=J+1;
  36.         }
  37.  
  38.  
  39. }
The function code worked fine when it was in the main body, so since putting it in a function, I'm guessing it has to do with how the fprint is reading it... Maybe an ampersand or something needs to be there?
Nov 16 '09 #7
JonathanS
37 New Member
What is H in your function? Is it possible you want J<H? if you're writing too far on your array you might be corrupting the memory surrounding it. One way to check the fprintf is to test it with a plain printf. It could be your formatting but that looks ok.
Nov 16 '09 #8
lordhoban
8 New Member
H is the universal counter. Basically, H is added onto for every record that was added to the report. So every record in each array will be totalled. I'll do a printf test.
Nov 16 '09 #9
lordhoban
8 New Member
I did the printf test and it produced the same output. I've tried making the values float, and they just produce different wacky output.

Could it have anything to do with the arrays being global values? They worked fine when everything was in the main body, but maybe it is having problems calculating inside the function with the global arrays?

If so, I don't know how to make the arrays work if they're not global.
Nov 16 '09 #10
lordhoban
8 New Member
Ok, here is the entire code. Maybe the errors will tell you something they don't tell me... I even included in //, where the function code used to be before being moved outside of the main body.

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. //Report Print Out
  5. #define REPORTHEADER "Employee         Pay       Reg Hrs       Gross      Fed        SSI      Net\n"
  6. #define REPORTHEADER2 "Name             Rate      Ovt Hrs       Pay        State      Defr     Pay\n"
  7. #define REPORTHEADER3  "========         ====      =======       =====      =====      ====     ===\n\n"
  8. #define REPORTFORMAT3 "%-2s, %-10s\n"
  9. #define REPORTFORMAT "                %6.2f%11.2f %13.2f %9.2f%11.2f%10.2f\n"
  10. #define REPORTFORMAT2 "                           %6.2f%24.2f%11.2f\n\n"
  11. #define REPORTFORMAT7 "Totals \n"
  12. #define REPORTFORMAT5 "                %3.2d%11.2d %13.2d %9.2d %11.2d%10.2d\n"
  13. #define REPORTFORMAT6 "                          %4.2d%24.2d %11.2d\n"
  14. #define REPORTFORMAT4 "Averages \n"
  15. #define REPORTFORMAT8 "                %3.2d%11.2d %13.2d %9.2d %11.2d%10.2d\n"
  16. #define REPORTFORMAT9 "                          %4.2d%24.2d %11.2d\n"
  17.  
  18.  
  19. //Tax Header
  20. #define FEDTAXRATE 0.15
  21. #define STATERATE 0.07
  22. #define SSIRATE 0.0775
  23.  
  24. //Declaring variables
  25. float calcFed[100]; //3.5.1
  26. float calcState[100]; //3.5.2
  27. float calcSSi[100]; //3.5.3
  28. float Hours[100], OvtHours[100], RegHours[100], Payrate[100], CalcGross[100], Deferred[100], TotTax;
  29. float NetPay[100]; // No instructions on Netpay, so I had to guess based on what the internet said of Netpay
  30. char FName[9],LName[9];
  31. char More; //Choice variable
  32. int H,AvgRate, AvgReg,
  33.                 AvgOvt, AvgGross, AvgFed, AvgState, AvgSSI, AvgNet, AvgDef;
  34.  
  35. void HeaD();
  36. int Ohours(int);
  37. //int Rhours(int);
  38. int GrOssP(int);
  39. int tAxes(int);
  40. void ToTaling(int &,int &,int &,int &,int &,int &,int &,int &,int &);
  41.              //int &TotalRate, int &TotalRegHours, int &TotalOvtHours, int &TotalGrossPay,
  42. //             int &TotalFedTax, int &TotalStateTax, int &TotalSSITax, int &TotalDeferred,
  43. //             int &TotalNet);
  44.  
  45.  
  46. void HeaD()
  47. {
  48.     FILE * reportFile; // create FILE * variable
  49.  
  50.     reportFile = fopen("./report.txt","wt"); // To open the file
  51.     if (reportFile == NULL) // To give an error message if file doesn't open.
  52.     {
  53.         printf("  Report file failed to open ...\n");
  54.         exit(-10); // reqs <stdlib.h>
  55.     }
  56.     fprintf(reportFile,REPORTHEADER); // Printing the Header files.
  57.     fprintf(reportFile,REPORTHEADER2); // Printing the Header files.
  58.     fprintf(reportFile,REPORTHEADER3); // Printing the Header files.
  59.     fclose(reportFile); // close the file
  60.     fflush(stdin);
  61. }
  62.  
  63.  
  64. int main(void)
  65. {
  66.  
  67. int TotalRate, TotalRegHours, TotalOvtHours, TotalGrossPay, TotalFedTax,
  68.     TotalStateTax,TotalSSITax, TotalDeferred,TotalNet;
  69.  
  70.     printf("Input a record? Yes(y) or No(n)?");
  71.     scanf("%s",&More);
  72.     if (More!='y'&&More!='Y')exit(-10);
  73.  
  74.     HeaD();
  75.  
  76. while (More=='y'||More=='Y') //Begin main while loop
  77. {
  78.     FILE * reportFile; // create FILE * variable
  79.  
  80.     reportFile = fopen("./report.txt","a+"); // To open the file
  81.     if (reportFile == NULL)
  82.     {
  83.         printf("  Report file failed to open ...\n");
  84.         exit(-10); 
  85.     }
  86.  
  87.     //Inputting information
  88.     printf("Input Employee's First Name: \n");
  89.     scanf("%s",&FName);
  90.     printf("Input Employee's Last Name: \n");
  91.     scanf("%s",&LName);
  92.     printf("Input Hours worked: \n");
  93.     scanf("%f",&Hours[H+1]);
  94.     printf("Enter Employee's Payrate: \n");
  95.     scanf("%f",&Payrate[H+1]);
  96.     printf("Enter Deferred Payment: \n");
  97.     scanf("%f",&Deferred[H+1]);
  98.  
  99.     Ohours(OvtHours[H+1]);
  100. //    Rhours(RegHours[H+1]);
  101.     GrOssP(CalcGross[H+1]);
  102.     tAxes(calcFed[H+1]);
  103.  
  104.         H=H+1; //accumilator
  105.  
  106.         //The following prints to screen some info you just entered.
  107.         printf("Employee Name: %-2s, %-10s\n\n", LName, FName); 
  108.         printf("Over Time: %.2f hours\n\n", OvtHours[H]);
  109.         printf("Gross Pay: %.2f\n\n", CalcGross[H]);
  110.         printf("Net Pay: %.2f\n\n", NetPay[H]);
  111.  
  112.  
  113.     //First part of putting values in a file.
  114.     fprintf(reportFile,REPORTFORMAT3,LName,FName);
  115.       fprintf(reportFile,REPORTFORMAT,Payrate[H],RegHours[H],CalcGross[H],calcFed[H],calcSSi[H],NetPay[H]);
  116.     fprintf(reportFile,REPORTFORMAT2,OvtHours[H],calcState[H],Deferred[H]);
  117.  
  118.     fclose(reportFile); // close the file
  119.     fflush(stdin);
  120.  
  121.             //The following allows the user to choose whether to keep computating.
  122.     printf("Input another record? Yes(y) or No(n)?");
  123.     scanf("%s",&More);
  124. }
  125.     FILE * reportFile; // create FILE * variable
  126.     reportFile = fopen("./report.txt","a+"); // To open the file
  127.  
  128.     if (reportFile == NULL)
  129.     {
  130.         printf("  Report file failed to open ...\n");
  131.         exit(-10); 
  132.     }
  133.  
  134.     ToTaling(TotalRate,TotalRegHours,TotalOvtHours,TotalGrossPay,
  135.              TotalFedTax,TotalStateTax,TotalSSITax,TotalDeferred,
  136.              TotalNet);
  137.       //Total Functions for each of the numerical columns
  138. //        int TotalRate=0,TotalRegHours=0,TotalOvtHours=0,TotalGrossPay=0,
  139. //            TotalFedTax=0,TotalStateTax=0,TotalSSITax=0,TotalDeferred=0,
  140. //            TotalNet=0;
  141. //    int J = 0;
  142. //        while (J<=H){
  143. //            TotalRate=TotalRate+Payrate[J]; // equals Total += Hours[J+1];
  144. //            TotalRegHours=TotalRegHours+RegHours[J]; // equals Total += Hours[J+1];
  145. //            TotalOvtHours=TotalOvtHours+OvtHours[J]; 
  146. //            TotalGrossPay=TotalGrossPay+CalcGross[J]; 
  147. //            TotalFedTax=TotalFedTax+calcFed[J]; 
  148. //            TotalStateTax=TotalStateTax+calcState[J]; 
  149. //            TotalSSITax=TotalSSITax+calcSSi[J]; 
  150. //            TotalDeferred=TotalDeferred+Deferred[J]; 
  151. //            TotalNet=TotalNet+NetPay[J]; // equals Total += Hours[J+1];
  152. //        J=J+1;
  153. //        }
  154.             //Averaging equations.
  155.         int AvgRate = TotalRate/H;
  156.         int AvgReg = TotalRegHours/H;
  157.         int AvgOvt = TotalOvtHours/H;
  158.         int AvgGross = TotalGrossPay/H;
  159.         int AvgFed = TotalFedTax/H;
  160.         int AvgState = TotalStateTax/H;
  161.         int AvgSSI = TotalSSITax/H;
  162.         int AvgNet = TotalNet/H;
  163.         int AvgDef = TotalDeferred/H;
  164.  
  165. //Final part of the report
  166. printf(REPORTFORMAT5,TotalRate,TotalRegHours,TotalGrossPay,TotalFedTax,TotalSSITax,TotalNet);
  167.     fprintf(reportFile,"\n\n");
  168.     fprintf(reportFile,REPORTFORMAT7);
  169.     fprintf(reportFile,REPORTFORMAT5,TotalRate,TotalRegHours,TotalGrossPay,TotalFedTax,TotalSSITax,TotalNet);
  170.     fprintf(reportFile,REPORTFORMAT6,TotalOvtHours,TotalStateTax,TotalDeferred);
  171.     fprintf(reportFile,"\n\n");
  172.     fprintf(reportFile,REPORTFORMAT4);
  173.     fprintf(reportFile,REPORTFORMAT8,AvgRate,AvgReg,AvgGross,AvgFed,AvgSSI,AvgNet);
  174.     fprintf(reportFile,REPORTFORMAT9,AvgOvt,AvgState,AvgDef);
  175.  
  176.     fclose(reportFile); // close the file
  177.  
  178.     fflush(stdin);
  179.     printf("Press any key and enter...\n");
  180.     getchar();
  181.     return 0;
  182. }
  183.  
  184. int Ohours(int)
  185. {
  186.         if (Hours[H+1]>40) 
  187.             OvtHours[H+1] = Hours[H+1] - 40; // Determines over time hours
  188.         else 
  189.             OvtHours[H+1] = 0; // Determines over time hours
  190.         if (Hours[H+1]>40) 
  191.             RegHours[H+1] = Hours[H+1] - OvtHours[H+1]; // Determines regular hours
  192.         else 
  193.             RegHours[H+1] = Hours[H+1]; // Determines regular hours
  194.         return OvtHours[H+1],RegHours[H+1];
  195. }
  196.  
  197. //int Rhours(int)
  198. //{
  199. //        if (Hours[H+1]>40) 
  200. //            RegHours[H+1] = Hours[H+1] - OvtHours[H+1]; // Determines regular hours
  201. //        else 
  202. //            RegHours[H+1] = Hours[H+1]; // Determines regular hours
  203. //        return RegHours[H+1];
  204. //}
  205.  
  206. int GrOssP(int)
  207. {
  208.     if (Hours[H+1]<=40) //Calculating Gross 
  209.         {
  210.                 CalcGross[H+1] = Hours[H+1] * Payrate[H+1];
  211.         }
  212.         else{
  213.                 CalcGross[H+1] = Payrate[H+1] * 40 + ((Hours[H+1] - 40)*1.5*Payrate[H+1]);
  214.         }
  215.         return CalcGross[H+1];
  216. }
  217.  
  218. int    tAxes(int)
  219.     {
  220.             //Calculating all tax based items. The below also takes into account
  221.             //having 0 gross pay means no taxes on that pay.
  222.         if (CalcGross[H+1]>0)calcFed[H+1] = (FEDTAXRATE * (CalcGross[H+1] - Deferred[H+1]));
  223.         if (CalcGross[H+1]>0)calcState[H+1] = (STATERATE * calcFed[H+1]);
  224.         if (CalcGross[H+1]>0)calcSSi[H+1] = (STATERATE * (CalcGross[H+1] - Deferred[H+1]));
  225.         TotTax=calcFed[H+1]+calcState[H+1]+calcSSi[H+1]; //Combining all tax for...
  226.         NetPay[H+1]=CalcGross[H+1]-TotTax; //...defining NetPay
  227.         return calcFed[H+1],calcState[H+1],calcSSi[H+1],TotTax,NetPay[H+1];
  228.     }
  229.  
  230.  
  231.       //Total Functions for each of the numerical columns
  232. void ToTaling(int &TotalRate, int &TotalRegHours, int &TotalOvtHours, int &TotalGrossPay,
  233.              int &TotalFedTax, int &TotalStateTax, int &TotalSSITax, int &TotalDeferred,
  234.              int &TotalNet)
  235. {
  236.     int J = 0;
  237.         while (J<=H){
  238.             TotalRate=TotalRate+Payrate[J]; // equals Total += Hours[J+1];
  239.             TotalRegHours=TotalRegHours+RegHours[J]; // equals Total += Hours[J+1];
  240.             TotalOvtHours=TotalOvtHours+OvtHours[J]; 
  241.             TotalGrossPay=TotalGrossPay+CalcGross[J]; 
  242.             TotalFedTax=TotalFedTax+calcFed[J]; 
  243.             TotalStateTax=TotalStateTax+calcState[J]; 
  244.             TotalSSITax=TotalSSITax+calcSSi[J]; 
  245.             TotalDeferred=TotalDeferred+Deferred[J]; 
  246.             TotalNet=TotalNet+NetPay[J]; // equals Total += Hours[J+1];
  247.         J=J+1;
  248.         }
  249.  
  250.  
  251. }
Nov 16 '09 #11
Banfa
9,065 Recognized Expert Moderator Expert
You say you are getting compiler errors and warnings but you haven't posted them. Please do post them and if necessary translate the line numbers in the errors so they match your posted code.

When post code please don't use [quote] ... [/quote] tags round it, instead use [code] ... [/code] tags which among other things preserve white space..
Nov 16 '09 #12
lordhoban
8 New Member
(It won't let me edit the code, so I can't go back and put it in brackets)
ERRORS (the fopen/etc type of errors should be ignored, as I will be moving this code into unix, and they need the original fopen type of commands):
Expand|Select|Wrap|Line Numbers
  1. Warning    1    warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    52    Employ2
  2. Warning    2    warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    73    Employ2
  3. Warning    3    warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    82    Employ2
  4. Warning    4    warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    91    Employ2
  5. Warning    5    warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    93    Employ2
  6. Warning    6    warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    95    Employ2
  7. Warning    7    warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    97    Employ2
  8. Warning    8    warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    99    Employ2
  9. Warning    9    warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    101    Employ2
  10. Warning    10    warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    103    Employ2
  11. Warning    11    warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    104    Employ2
  12. Warning    12    warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    125    Employ2
  13. Warning    13    warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    128    Employ2
  14. Warning    14    warning C4244: 'return' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    196    Employ2
  15. Warning    15    warning C4244: '=' : conversion from 'double' to 'float', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    215    Employ2
  16. Warning    16    warning C4244: 'return' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    217    Employ2
  17. Warning    17    warning C4244: '=' : conversion from 'double' to 'float', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    224    Employ2
  18. Warning    18    warning C4244: '=' : conversion from 'double' to 'float', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    225    Employ2
  19. Warning    19    warning C4244: '=' : conversion from 'double' to 'float', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    226    Employ2
  20. Warning    20    warning C4244: 'return' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    229    Employ2
  21. Warning    21    warning C4244: '=' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    240    Employ2
  22. Warning    22    warning C4244: '=' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    241    Employ2
  23. Warning    23    warning C4244: '=' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    242    Employ2
  24. Warning    24    warning C4244: '=' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    243    Employ2
  25. Warning    25    warning C4244: '=' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    244    Employ2
  26. Warning    26    warning C4244: '=' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    245    Employ2
  27. Warning    27    warning C4244: '=' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    246    Employ2
  28. Warning    28    warning C4244: '=' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    247    Employ2
  29. Warning    29    warning C4244: '=' : conversion from 'float' to 'int', possible loss of data    i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp    248    Employ2
  30.  
Nov 16 '09 #13
donbock
2,426 Recognized Expert Top Contributor
@lordhoban
You should refer to the online help for details. I don't know if you should use the secure versions of these functions. If you decide to use the standard functions then you should disable deprecation. My guess is you do this by defining macro _CRT_SECURE_NO_WARNINGS at the top of your source file, before you include any headers; but the best thing for you to do is ignore that advice and look it up in your online help.

The warning text complains about your use of 'fopen' on line 52 of employmain11.cpp. You actually call 'fopen' on line 51. This is pretty close, but other warnings have larger discrepancies in the line number. This leads me to believe that the code in your post is not a precise copy of employmain11.cpp. That's ok -- we encourage you to post a relevant snippet to increase the signal-to-noise ratio. But we rely on you to modify the compiler warnings so that the line numbers in the warning text refer to the line numbers in your posted snippet. It will be a lot easier to help if you repost the compiler warnings after adjusting the line numbers.
Nov 16 '09 #14

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

Similar topics

5
2910
by: lawrence | last post by:
I've this function, which is the method of a class. I'm posting the constructor of the class down below. For some reason, when I fill out a form and hit submit, I'm not getting any values. Can...
15
2325
by: Bob | last post by:
I've tried everything; and I can't seem to get past this VERY (seemingly) simply problem. I want to work with an array variable within a function(s). I can't get it to work; if I: 1) global...
2
3039
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
2
3275
by: David Williams | last post by:
Hi Guys, I have a couple of problems. The first is (I believe) a simple syntactic problem you can probably solve quite easily. The second is a design style problem which might be more tricky... ...
14
2551
by: Jeroen | last post by:
Hi all, I've got a question about writing a library. Let me characterize that library by the following: * there is a class A which is available to the user * there is a class B that is used...
1
2191
by: joeedh | last post by:
Hi I'm getting extremely odd behavior. First of all, why isn't PyEval_EvalCode documented anywhere? Anyway, I'm working on blender's python integration (it embeds python, as opposed to python...
4
8356
by: Aaryan123 | last post by:
Function to check a number between a range in perl ========================================= Back ground: This situation has been fixed in Perl5.005. Use of .. in a for loop will iterate over...
9
1983
by: Erwin Moller | last post by:
Hi all, Is it possible (PHP5.2) to find the name of a variable used in the caller of a function from within the function itself? Or to be more clear: ...php code.. $result = foo($abc);...
49
2671
by: Davy | last post by:
Hi all, I am writing a function, which return the pointer of the int. But it seems to be wrong. Any suggestion? int * get_p_t(int t) { return &t; } int main()
0
7192
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,...
0
7064
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...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4991
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...
0
4665
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1492
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.