473,378 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

error: expected expression before 'int'

My program was running fine under visual studio, but I moved it over to Linux, and have run into one problem I have no idea how to fix.

error: expected expression before 'int'

(all the following lines cause the error. Obviously it is what I'm doing with the INT that is the problem);

CEnts = NetPay - int(NetPay);
numHuns = int(NetPay)/100;

numHuns = int(NetPay)/1000;
numTens = int(NetPay) % 100 / 10;
numOnes = int(NetPay) % 100 % 10;
RemainDER=int(NetPay) % 100;

int CEnts3 = int(CEnts);

I used INT as a way of cutting a float down, eliminating numbers smaller than whole numbers. Any ideas or workarounds?
Dec 10 '09 #1
2 21835
Banfa
9,065 Expert Mod 8TB
Actually my experience with that error message is that it means something has gone wrong before the actual location where it is reported. Also if it was a problem with the code you have posted then presumably this would give the same error

Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.     float NetPay = 2233.545f;
  4.     int numHuns = int(NetPay)/1000;
  5. }
  6.  
but this compiles without errors.

Post a little more of the code for one of the examples.
Dec 10 '09 #2
weaknessforcats
9,208 Expert Mod 8TB
Avoid using floating point for money. Because of rounding, things will never add up correctly.

Use integers and keep your amounts in pennies.

You can always display an int with 1234 as a value as $12.34.

You don't need a decimal point except for the human eyeball.
Dec 10 '09 #3

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

Similar topics

4
by: learning_C++ | last post by:
Hi, I try to use input = new istrstream(argv,strlen(argv)); in my code, but it always says error: " error: parse error before `(' token" please help me! Thanks, #include <map>
7
by: Spacen Jasset | last post by:
The main two desirable things I feel error handling should provide are these: 1) Debugging and diagnostic aid 2) User feedback One method that is used a fair amount it to 'say' that all...
1
by: Carlos Kim via DotNetMonster.com | last post by:
Compiler Error Message: CS1026: ) expected Source Error: Line 12: <body MS_POSITIONING="GridLayout"> Line 13: <form id="Form1" method="post" runat="server"> Line 14:...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
4
by: Gary Wessle | last post by:
Hi I have been trying to find out the reason for this error for an 1hr, please look at it for me. thanks **************** error **************** $ make; ./proj g++ -gdwarf-2 -c -o...
13
by: hn.ft.pris | last post by:
Hi: I have the following simple program: #include<iostream> using namespace std; int main(int argc, char* argv){ const double L = 1.234; const int T = static_cast<const int>(L); int arr;
8
by: dotyet | last post by:
Hi Everyone, I am learning how to write C++ programs for DB2. My primary area of concern would be the administrative level DB2 APIs. For the time being, I am also looking at how to create...
6
by: Lawrence Spector | last post by:
I ran into a problem using g++. Visual Studio 2005 never complained about this, but with g++ I ran into this error. I can't figure out if I've done something wrong or if this is a compiler bug. ...
9
by: Rohit | last post by:
I am trying to initialize an array whose initializers depend on value of Enums. I take enum and then decide the initializer value, so that even if enum value changes because of addition to list...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.