473,322 Members | 1,614 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,322 software developers and data experts.

Error: C requires whitespace after the macro name

[Warning] ISO C requires whitespace after the macro name

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. #include <fstream>
  5.  
  6. #define a=5.5         // 1
  7. #define b=6          //  2
  8. #define c=7         //   3
  9. #define d=9        //    4
  10. #define e=12      //Rate 5
  11.  
  12.  #define USE_PAUSE 0    // set to 1 to add a pause at the end of the program
  13.  #define DEBUG 1        // set to 1 to enable debug prints and disable clear screen
  14. using namespace std;
  15. /******************************* main *******************************/
  16.  
  17. int main()
  18. {                                                     
  19.     char    part_desc[26],           
  20.             drive[2],         // user output drive
  21.             disk_file[15],   // full name and destination of output file
  22.             file[9];        // user output file name
  23.  
  24.     ofstream    outfile;       // output stream name
  25.  
  26.     unsigned int     choice,             // user output choice
  27.  
  28.                                                      //Program Declarations
  29.              ID, clas, time,  //ID number, classification, worked hour
  30.              overtime; //overtimed hours of work
  31.              float rate, pay, //hourly rate, Regular Pay of 40-hours 
  32.     overpay, total;   //pay from overtimed hours of work, Total Earning
  33.  
  34.     string name;            //name of Employee
  35.  
  36.     /******************* INPUT SECTION  **********************/
  37.                            #if DEBUG 
  38.             cout << "Starting INPUT SECTION" << endl;
  39.                              #endif        
  40.  
  41.  cout<< "[Enter] Employee's name: "; cin>>name;      /*Employee's name */
  42.  cout<< "[Enter] Employee's ID: "; cin>>ID;          /*Employee's  ID  */
  43.  cout<< "[Enter] Employee's Job Class: "; cin>>clas; /*Employee's class*/
  44.  cout<< "[Enter] Employee's # of Hours: ";cin>>time; /*Employee's hour */
  45.  
  46.     /***************** PROCESSING SECTION  *******************/ 
  47.                            #if DEBUG
  48.              cout << "Starting PROCESSING SECTION" << endl;
  49.                              #endif     
  50.  
  51.  //Classification      //Regular Pay
  52.  rate = clas==1 ? a;   pay = 40 * rate;
  53.  rate = clas==2 ? b;   //Overtime hours      //Total Earnings
  54.  rate = clas==3 ? c;   overtime = time-40;   total = overpay + pay;
  55.  rate = clas==4 ? d;   //Overpay
  56.  rate = clas==5 ? e;   overpay = overtime * (rate * 1.5);
  57.  rate = clas!=1|2|3|4|5 ? a;
  58.  
  59.     /******************* OUTPUT SECTION  *********************/
  60.                            #if DEBUG
  61.                cout << "Starting OUTPUT SECTION" << endl;
  62.                              #endif
  63.  
  64.  cout<< "WorkHard Corporation\n" << "====================\n\n"
  65.  << "Employee Name: "<< name<< "ID. Number: "<< ID << "\n\n"     /*name & ID*/
  66.  << "Job Classification: "<< clas               /*class*/
  67.  << "Hourly Rate: "<< setprecision(2) << fixed<< rate
  68.  << "Total Hours Worked: "<< time
  69.  << "Overtime Hours: "<< overtime << "\n\n"
  70.  
  71.  << "Regular Pay: "<< setprecision(2)<< fixed<< pay
  72.  << "Overtime Pay: "<< setprecision(2)<< fixed<<  overpay<< "\n\n"
  73.  
  74.  << "Total Earning: "<< setprecision(2)<< fixed<< total<< "\n\n";
  75.  
  76.  if (hour < 40)
  77.  cout<< "Inadequate number of hours worked!";
  78. else if (hour > 60)
  79.  cout<< "Excessive number of hours Worked!";
  80.  
  81.  system ("pause");
  82.  
  83. /*********************** output―Locator ***********************/    
  84.                            #if !DEBUG
  85.                          system ("cls");
  86.                              #endif   
  87.  
  88.      cout  <<  "Output to console (1) or disk file (2): ";
  89.      cin  >>  choice;
  90.  
  91. /**/ if ( choice  ==  1 )
  92. /**/{ 
  93. /**/                       #if !DEBUG
  94. /**/                     system ("cls");
  95. /**/                         #endif
  96. /**/                   outfile.open("con");
  97. /**/}
  98. /**/ else
  99. /**/{ 
  100. /**/    cout  <<  "Which drive: a, b, c, d, e, or f ? ";
  101. /**/    cin  >>  drive;      
  102. /**/    strcpy(disk_file, drive);
  103. /**/    strcat(disk_file, ":");
  104. /**/    cout  <<  "Enter a results file name: ";
  105. /**/    cin  >>  file;
  106. /**/    strcat(disk_file, file);
  107. /**/    strcat(disk_file, ".txt");
  108. /**/    outfile.open(disk_file);
  109. /**/}
  110.  
  111.  outfile << setiosflags(ios::showpoint | ios::fixed) << setprecision(2);
  112.  
  113. /**/outfile <<setw(53)<< "Mini Calculator\n\n"
  114. /**/<<setw(24)<<"Operand 1"<<setw(48)<<"Operand 2\n"
  115. /**/<<setw(24)<< op<<setw(47)<< op2<< "\n\n" 
  116.  
  117. /**/<<setw(10)<< "Sum"<<setw(17)<< "Difference"<<setw(14)<< "Product"
  118. /**/<<setw(21)<< "Whole Quotient"<<setw(16)<< "Remainder\n"
  119. /**/<<setw(10)<< op+op2<<setw(17)<< op-op2<<setw(14)<< op*op2
  120. /**/<<setw(21)<< op/op2<<setw(15)<< op%op2<< "\n\n\n"
  121.  
  122. /**/<<setw(14)<<"Real Quotient"<<setw(31)<<"Square Root of Operand 1"
  123. /**/<<setw(34)<<"Operand 2 to the power of 4"
  124. /**/<<setw(15)<<setprecision(2)<<fixed<< float(op)/op2
  125. /**/<<setw(31)<< sqrt(op)
  126. /**/<<setw(34)<< int(pow(op2,4.0))<< "\n\n";
  127.  
  128.     outfile.close();
  129.     system ("cls");
  130. return 0;
  131. }
  132.  
Mar 15 '13 #1

✓ answered by weaknessforcats

So what's the //1 for?

Expand|Select|Wrap|Line Numbers
  1. #define a=5.5         // 1
It's not part of the macro and the macro is not C++.

Remember, all lines beginning with a # belong to the preprocessor so you need to follow preprocessor rules n those lines

You will need to fix the other #define's as well.

2 15253
weaknessforcats
9,208 Expert Mod 8TB
So what's the //1 for?

Expand|Select|Wrap|Line Numbers
  1. #define a=5.5         // 1
It's not part of the macro and the macro is not C++.

Remember, all lines beginning with a # belong to the preprocessor so you need to follow preprocessor rules n those lines

You will need to fix the other #define's as well.
Mar 15 '13 #2
outfile is ignored; I require help with rate = clas==1 ? a; and other conditionals.

alright

mm..no error to the commentaries.

I assume it's the conditionals; maybe, the compiler doesn't know them.

#define(d) variables are old? It worked for my calculator program lol
Mar 15 '13 #3

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

Similar topics

1
by: Jim | last post by:
Im trying to find the error in this statement: CREATE PROCEDURE STP_selectmain AS select a.inventoryid, b.firstname, b.lastname, art.title, art.medium, a.cost, a.inventoryid,...
1
by: D Senthil Kumar | last post by:
Hi, Is it possible to get the name of the macro from that macro itself. Thank you in advance.
17
by: sounak | last post by:
How could we get a macro name from a macro value such that in a header file #define a 100 #define b 200 now the source file will be such that the user gives 100 then the value is outputted as...
5
by: aspineux | last post by:
I want to parse 'foo@bare' or '<foot@bar>' and get the email address foo@bar the regex is r'<\w+@\w+>|\w+@\w+' now, I want to give it a name
5
by: elecooley | last post by:
Baically, myself and the person I sit next to use a shortcut to an Excel file. The Excel file has multiple macros. When office mate opens it, it works fine (ie all macros run, excel file gets data,)....
1
by: Jeff | last post by:
I am receiving the following error: // error: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 No...
3
by: ChipR | last post by:
I'm using strFileName = "\\serverName\folderName\fileName.txt" If Dir(strFileName) > "" Then ... This worked fine for me, even when I disconnected from the network, but when a user ran it on...
4
by: James Lucero | last post by:
Below is my code. The error is "Compile Error Variable not defined". wdOrientLandscape is highlighted. Again this the portion of the code from a VB module created in Excel. The previous lines of code...
1
by: Harshini Raj | last post by:
Hi, I am unable to fix this error. Canyou tell me what compiler options i have to use to fix this issue? Issue Error 40:Undeclared identifier 'Name' -- Within an expression, an identifier was...
3
by: mahmoodn | last post by:
Hi, I have a struct with this definition struct SeverityAction : public Action { uint32_t theSeverity; //***** public: SeverityAction(uint32_t aSeverity); ... };
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.