User Profile

Collapse

Profile Sidebar

Collapse
lordhoban
lordhoban
Last Activity: Dec 10 '09, 05:37 AM
Joined: Nov 15 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • lordhoban
    started a topic error: expected expression before 'int'
    in C

    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;...
    See more | Go to post

  • (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):
    Code:
    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
    ...
    See more | Go to post

    Leave a comment:


  • 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.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    //Report Print Out
    #define REPORTHEADER "Employee         Pay       Reg Hrs       Gross      Fed        SSI      Net\n"
    #define REPORTHEADER2
    ...
    See more | Go to post

    Leave a comment:


  • 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.
    See more | Go to post

    Leave a comment:


  • 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.
    See more | Go to post

    Leave a comment:


  • 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:
    Code:
    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"
    ...
    See more | Go to post

    Leave a comment:


  • 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...
    See more | Go to post

    Leave a comment:


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

    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)
    ...
    See more | Go to post
No activity results to display
Show More
Working...