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!
13 2034 -
ToTaling(&TotalRate,&TotalRegHours,&TotalOvtHours, &TotalGrossPay,
-
&TotalFedTax,&TotalStateTax,&TotalSSITax,&TotalDef erred,
-
&TotalNet);
-
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)
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...
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.
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.
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.
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: - void ToTaling(int &,int &,int &,int &,int &,int &,int &,int &,int &);
-
-
#define REPORTFORMAT7 "Totals \n"
-
#define REPORTFORMAT5 " %3.2d%11.2d %13.2d %9.2d %11.2d%10.2d\n"
-
#define REPORTFORMAT6 " %4.2d%24.2d %11.2d\n"
-
-
-
Main body:
-
int TotalRate, TotalRegHours, TotalOvtHours, TotalGrossPay, TotalFedTax,
-
TotalStateTax,TotalSSITax, TotalDeferred,TotalNet;
-
-
ToTaling(TotalRate,TotalRegHours,TotalOvtHours,TotalGrossPay,
-
TotalFedTax,TotalStateTax,TotalSSITax,TotalDeferred, TotalNet);
-
-
fprintf(reportFile,REPORTFORMAT7);
-
fprintf (reportFile,REPORTFORMAT, TotalRate,TotalRegHours,TotalGrossPay, TotalFedTax,TotalSSITax,TotalNet);
-
fprintf(reportFile,REPORTFORMAT ,TotalOvtHours,TotalStateTax,TotalDeferred);
-
-
AND ACTUAL function:
-
void ToTaling(int &TotalRate, int &TotalRegHours, int &TotalOvtHours, int &TotalGrossPay,
-
int &TotalFedTax, int &TotalStateTax, int &TotalSSITax, int &TotalDeferred,
-
int &TotalNet)
-
{
-
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;
-
}
-
-
-
}
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?
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.
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.
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.
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. - #include <stdio.h>
-
#include <stdlib.h>
-
-
//Report Print Out
-
#define REPORTHEADER "Employee Pay Reg Hrs Gross Fed SSI Net\n"
-
#define REPORTHEADER2 "Name Rate Ovt Hrs Pay State Defr Pay\n"
-
#define REPORTHEADER3 "======== ==== ======= ===== ===== ==== ===\n\n"
-
#define REPORTFORMAT3 "%-2s, %-10s\n"
-
#define REPORTFORMAT " %6.2f%11.2f %13.2f %9.2f%11.2f%10.2f\n"
-
#define REPORTFORMAT2 " %6.2f%24.2f%11.2f\n\n"
-
#define REPORTFORMAT7 "Totals \n"
-
#define REPORTFORMAT5 " %3.2d%11.2d %13.2d %9.2d %11.2d%10.2d\n"
-
#define REPORTFORMAT6 " %4.2d%24.2d %11.2d\n"
-
#define REPORTFORMAT4 "Averages \n"
-
#define REPORTFORMAT8 " %3.2d%11.2d %13.2d %9.2d %11.2d%10.2d\n"
-
#define REPORTFORMAT9 " %4.2d%24.2d %11.2d\n"
-
-
-
//Tax Header
-
#define FEDTAXRATE 0.15
-
#define STATERATE 0.07
-
#define SSIRATE 0.0775
-
-
//Declaring variables
-
float calcFed[100]; //3.5.1
-
float calcState[100]; //3.5.2
-
float calcSSi[100]; //3.5.3
-
float Hours[100], OvtHours[100], RegHours[100], Payrate[100], CalcGross[100], Deferred[100], TotTax;
-
float NetPay[100]; // No instructions on Netpay, so I had to guess based on what the internet said of Netpay
-
char FName[9],LName[9];
-
char More; //Choice variable
-
int H,AvgRate, AvgReg,
-
AvgOvt, AvgGross, AvgFed, AvgState, AvgSSI, AvgNet, AvgDef;
-
-
void HeaD();
-
int Ohours(int);
-
//int Rhours(int);
-
int GrOssP(int);
-
int tAxes(int);
-
void ToTaling(int &,int &,int &,int &,int &,int &,int &,int &,int &);
-
//int &TotalRate, int &TotalRegHours, int &TotalOvtHours, int &TotalGrossPay,
-
// int &TotalFedTax, int &TotalStateTax, int &TotalSSITax, int &TotalDeferred,
-
// int &TotalNet);
-
-
-
void HeaD()
-
{
-
FILE * reportFile; // create FILE * variable
-
-
reportFile = fopen("./report.txt","wt"); // To open the file
-
if (reportFile == NULL) // To give an error message if file doesn't open.
-
{
-
printf(" Report file failed to open ...\n");
-
exit(-10); // reqs <stdlib.h>
-
}
-
fprintf(reportFile,REPORTHEADER); // Printing the Header files.
-
fprintf(reportFile,REPORTHEADER2); // Printing the Header files.
-
fprintf(reportFile,REPORTHEADER3); // Printing the Header files.
-
fclose(reportFile); // close the file
-
fflush(stdin);
-
}
-
-
-
int main(void)
-
{
-
-
int TotalRate, TotalRegHours, TotalOvtHours, TotalGrossPay, TotalFedTax,
-
TotalStateTax,TotalSSITax, TotalDeferred,TotalNet;
-
-
printf("Input a record? Yes(y) or No(n)?");
-
scanf("%s",&More);
-
if (More!='y'&&More!='Y')exit(-10);
-
-
HeaD();
-
-
while (More=='y'||More=='Y') //Begin main while loop
-
{
-
FILE * reportFile; // create FILE * variable
-
-
reportFile = fopen("./report.txt","a+"); // To open the file
-
if (reportFile == NULL)
-
{
-
printf(" Report file failed to open ...\n");
-
exit(-10);
-
}
-
-
//Inputting information
-
printf("Input Employee's First Name: \n");
-
scanf("%s",&FName);
-
printf("Input Employee's Last Name: \n");
-
scanf("%s",&LName);
-
printf("Input Hours worked: \n");
-
scanf("%f",&Hours[H+1]);
-
printf("Enter Employee's Payrate: \n");
-
scanf("%f",&Payrate[H+1]);
-
printf("Enter Deferred Payment: \n");
-
scanf("%f",&Deferred[H+1]);
-
-
Ohours(OvtHours[H+1]);
-
// Rhours(RegHours[H+1]);
-
GrOssP(CalcGross[H+1]);
-
tAxes(calcFed[H+1]);
-
-
H=H+1; //accumilator
-
-
//The following prints to screen some info you just entered.
-
printf("Employee Name: %-2s, %-10s\n\n", LName, FName);
-
printf("Over Time: %.2f hours\n\n", OvtHours[H]);
-
printf("Gross Pay: %.2f\n\n", CalcGross[H]);
-
printf("Net Pay: %.2f\n\n", NetPay[H]);
-
-
-
//First part of putting values in a file.
-
fprintf(reportFile,REPORTFORMAT3,LName,FName);
-
fprintf(reportFile,REPORTFORMAT,Payrate[H],RegHours[H],CalcGross[H],calcFed[H],calcSSi[H],NetPay[H]);
-
fprintf(reportFile,REPORTFORMAT2,OvtHours[H],calcState[H],Deferred[H]);
-
-
fclose(reportFile); // close the file
-
fflush(stdin);
-
-
//The following allows the user to choose whether to keep computating.
-
printf("Input another record? Yes(y) or No(n)?");
-
scanf("%s",&More);
-
}
-
FILE * reportFile; // create FILE * variable
-
reportFile = fopen("./report.txt","a+"); // To open the file
-
-
if (reportFile == NULL)
-
{
-
printf(" Report file failed to open ...\n");
-
exit(-10);
-
}
-
-
ToTaling(TotalRate,TotalRegHours,TotalOvtHours,TotalGrossPay,
-
TotalFedTax,TotalStateTax,TotalSSITax,TotalDeferred,
-
TotalNet);
-
//Total Functions for each of the numerical columns
-
// int TotalRate=0,TotalRegHours=0,TotalOvtHours=0,TotalGrossPay=0,
-
// TotalFedTax=0,TotalStateTax=0,TotalSSITax=0,TotalDeferred=0,
-
// TotalNet=0;
-
// 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;
-
// }
-
//Averaging equations.
-
int AvgRate = TotalRate/H;
-
int AvgReg = TotalRegHours/H;
-
int AvgOvt = TotalOvtHours/H;
-
int AvgGross = TotalGrossPay/H;
-
int AvgFed = TotalFedTax/H;
-
int AvgState = TotalStateTax/H;
-
int AvgSSI = TotalSSITax/H;
-
int AvgNet = TotalNet/H;
-
int AvgDef = TotalDeferred/H;
-
-
//Final part of the report
-
printf(REPORTFORMAT5,TotalRate,TotalRegHours,TotalGrossPay,TotalFedTax,TotalSSITax,TotalNet);
-
fprintf(reportFile,"\n\n");
-
fprintf(reportFile,REPORTFORMAT7);
-
fprintf(reportFile,REPORTFORMAT5,TotalRate,TotalRegHours,TotalGrossPay,TotalFedTax,TotalSSITax,TotalNet);
-
fprintf(reportFile,REPORTFORMAT6,TotalOvtHours,TotalStateTax,TotalDeferred);
-
fprintf(reportFile,"\n\n");
-
fprintf(reportFile,REPORTFORMAT4);
-
fprintf(reportFile,REPORTFORMAT8,AvgRate,AvgReg,AvgGross,AvgFed,AvgSSI,AvgNet);
-
fprintf(reportFile,REPORTFORMAT9,AvgOvt,AvgState,AvgDef);
-
-
fclose(reportFile); // close the file
-
-
fflush(stdin);
-
printf("Press any key and enter...\n");
-
getchar();
-
return 0;
-
}
-
-
int Ohours(int)
-
{
-
if (Hours[H+1]>40)
-
OvtHours[H+1] = Hours[H+1] - 40; // Determines over time hours
-
else
-
OvtHours[H+1] = 0; // Determines over time hours
-
if (Hours[H+1]>40)
-
RegHours[H+1] = Hours[H+1] - OvtHours[H+1]; // Determines regular hours
-
else
-
RegHours[H+1] = Hours[H+1]; // Determines regular hours
-
return OvtHours[H+1],RegHours[H+1];
-
}
-
-
//int Rhours(int)
-
//{
-
// if (Hours[H+1]>40)
-
// RegHours[H+1] = Hours[H+1] - OvtHours[H+1]; // Determines regular hours
-
// else
-
// RegHours[H+1] = Hours[H+1]; // Determines regular hours
-
// return RegHours[H+1];
-
//}
-
-
int GrOssP(int)
-
{
-
if (Hours[H+1]<=40) //Calculating Gross
-
{
-
CalcGross[H+1] = Hours[H+1] * Payrate[H+1];
-
}
-
else{
-
CalcGross[H+1] = Payrate[H+1] * 40 + ((Hours[H+1] - 40)*1.5*Payrate[H+1]);
-
}
-
return CalcGross[H+1];
-
}
-
-
int tAxes(int)
-
{
-
//Calculating all tax based items. The below also takes into account
-
//having 0 gross pay means no taxes on that pay.
-
if (CalcGross[H+1]>0)calcFed[H+1] = (FEDTAXRATE * (CalcGross[H+1] - Deferred[H+1]));
-
if (CalcGross[H+1]>0)calcState[H+1] = (STATERATE * calcFed[H+1]);
-
if (CalcGross[H+1]>0)calcSSi[H+1] = (STATERATE * (CalcGross[H+1] - Deferred[H+1]));
-
TotTax=calcFed[H+1]+calcState[H+1]+calcSSi[H+1]; //Combining all tax for...
-
NetPay[H+1]=CalcGross[H+1]-TotTax; //...defining NetPay
-
return calcFed[H+1],calcState[H+1],calcSSi[H+1],TotTax,NetPay[H+1];
-
}
-
-
-
//Total Functions for each of the numerical columns
-
void ToTaling(int &TotalRate, int &TotalRegHours, int &TotalOvtHours, int &TotalGrossPay,
-
int &TotalFedTax, int &TotalStateTax, int &TotalSSITax, int &TotalDeferred,
-
int &TotalNet)
-
{
-
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;
-
}
-
-
-
}
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..
(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): -
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
Warning 9 warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 101 Employ2
-
Warning 10 warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 103 Employ2
-
Warning 11 warning C4244: 'argument' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 104 Employ2
-
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
-
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
-
Warning 14 warning C4244: 'return' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 196 Employ2
-
Warning 15 warning C4244: '=' : conversion from 'double' to 'float', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 215 Employ2
-
Warning 16 warning C4244: 'return' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 217 Employ2
-
Warning 17 warning C4244: '=' : conversion from 'double' to 'float', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 224 Employ2
-
Warning 18 warning C4244: '=' : conversion from 'double' to 'float', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 225 Employ2
-
Warning 19 warning C4244: '=' : conversion from 'double' to 'float', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 226 Employ2
-
Warning 20 warning C4244: 'return' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 229 Employ2
-
Warning 21 warning C4244: '=' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 240 Employ2
-
Warning 22 warning C4244: '=' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 241 Employ2
-
Warning 23 warning C4244: '=' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 242 Employ2
-
Warning 24 warning C4244: '=' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 243 Employ2
-
Warning 25 warning C4244: '=' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 244 Employ2
-
Warning 26 warning C4244: '=' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 245 Employ2
-
Warning 27 warning C4244: '=' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 246 Employ2
-
Warning 28 warning C4244: '=' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 247 Employ2
-
Warning 29 warning C4244: '=' : conversion from 'float' to 'int', possible loss of data i:\classstructuredpro\latest\latestemploynov16\employmain11.cpp 248 Employ2
-
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
...
|
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...
| |
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...
|
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...
|
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);...
|
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()
|
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,...
|
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...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |