Thread: Why does it work in Visual Studio and Not Borland

  1. #1
    MonteMan
    Guest

    Why does it work in Visual Studio and Not Borland

    My project is nearly done however the teacher is running Borland and I am running Visual Studio. The Program is about 99% working but when I put it in Borland it doesn't work and gives me all these link errors. Can someone help me remmedy this problem ?

  2. #2
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    you're going to have to help us a little on what these errors are
    hello, internet!

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Judging by the vagueness of the question I can only give you a general answer. I may make many jokes at borlands expense but it does at least conform to the standards. VC++ doesn't always do this. This could be your problem. Or the version of the borland compiler may be older and some libraries you are using may not be supported (if your a newbie I'm doubtful that this is the case). Are you running the same OS's in both cases?

  4. #4
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    Or to rephrase what master said... VC++ may allow you to write things that are not standard code, hence Borland pukes on it.

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    52

    Found my old user Name :-)

    Hehe I finally found my user name :-) Anyhow if I were o post my code do you guys think you could maybe point out what Borland Pukes on ???

    Also maybe you could help me two things
    -On the output.txt file I need it to set presision to two dec. points however when I do the set pression command I only get two numbers !?!?!?!
    -There is an error in my code that computes all emplyees axcept for my last one?

    Other than that, she works like a million bucks ( This is my first major C++ project so I am pretty happy with myself thus far)
    Code:
    #include<iostream.h>
    #include<fstream.h>
    #include<iomanip.h>
    
    int process_employee(int& empnum, float& emprate, float& emphours, ifstream& inData);
    void process_payroll(ifstream& inData, ofstream& outData, 
    					 const float& FEDERAL_TAX, 
    					 const float& STATE_TAX,
    					 const float& SOCSEC_TAX,
    					 float& totalGP, float& totalNP, float& totalFT, float& totalST,
    					 float& totalSS);
    void print_summary(ofstream& outData, float& totalGP, float& totalNP, 
    				  float& totalFT, float& totalST, float& totalSS);
    
    int main()
    {
    const float FEDERAL_TAX = .15; 
    const float STATE_TAX = .0524;
    const float SOCSEC_TAX = .07;
    
    float totalGP = 0, totalNP = 0, totalFT = 0, totalST = 0, totalSS = 0;
    char flag = ' ';
    int excesshours = 0;
    
    ifstream inData;
    ofstream outData;
    
    inData.open("A:\indata.txt", ios::in);
    outData.open("A:\outdata.txt", ios::out);
    
    process_payroll(inData, outData, FEDERAL_TAX, STATE_TAX, SOCSEC_TAX, totalGP, totalNP,
    				totalFT, totalST, totalSS);
    print_summary(outData, totalGP, totalNP, totalFT, totalST, totalSS);
    
    
    }
    
    int process_employee(int& empnum, float& emprate, float& emphours, ifstream& inData)
    {
      inData >> empnum;
      if(inData.eof()) return 0;
      
      inData >> emprate;
      if(inData.eof()) return 0;
    
      inData >> emphours;
      if(inData.eof()) return 0;
    
      return 1;
    }
    
    void process_payroll(ifstream& inData, ofstream& outData, 
    					 const float& FEDERAL_TAX, 
    					 const float& STATE_TAX,
    					 const float& SOCSEC_TAX,
    					 float& totalGP, float& totalNP, float& totalFT, float& totalST,
    					 float& totalSS)
    {
      int flag = 0;
      int empnum;
      float emprate, emphours, gross, paynet = 0, fed = 0, state = 0, socSec = 0;
      char rateType;
    
      outData << "Employee Payroll\n" << endl;
    
      outData << setw(10) << "Employee" << setw(10) << "Hours" << " " 
    	  << setw(10) << "Rate" << setw(10) << "Gross" << setw(10) << "Net"
           << setw(10) << "Fed"<< setw(10) <<  "State" << setw(10) << "Soc. Sec" << endl;
     
      flag = process_employee(empnum,emprate,emphours,inData);
      while(flag == 1)
      {
    	
    	  gross = (emprate * emphours);
    	  rateType = ' ';
    
    	  //$.15 bonus per hour for employees who work 35 hours or less
    	  if(emphours <= 35)
    	  {
    		  gross +=  .15 * emphours;
    		  rateType = '*';
    	  }
    	  
    	  if(emphours > 40)
    	  {
    		  //add overtime on top of regular wage
    			gross += (emprate * .5) * (emphours - 40);
    			rateType = '$';
    	  }
    
    	  fed = FEDERAL_TAX * gross;
    	  state = STATE_TAX * gross;
    	  socSec = SOCSEC_TAX * gross;
    
    	  paynet = gross - fed - state - socSec;
    
    	  //add up totals
    	  totalGP += gross;
    	  totalNP += paynet;
    	  totalFT += fed;
    	  totalST += state;
    	  totalSS += socSec;
    
    	  //print statements here for individual 
    
    	  outData <<  setw(10) << empnum << setw(10) << emphours << rateType 
    	   << setw(10) << emprate << setw(10) << gross << setw(10) << paynet
           << setw(10) << fed << setw(10) <<  state << setw(10) << socSec << endl; 
    
          flag = process_employee(empnum,emprate,emphours,inData);
    
      }
    }
    		  
    void print_summary(ofstream& outData, float& totalGP, float& totalNP, 
    				  float& totalFT, float& totalST, float& totalSS)
    {
      outData << "Summary-Totals for all employees\n" << endl;
    
      	  outData <<  setw(13) << "Gross Pay" << setw(13) << "Net Pay" << setw(13) 
    	  << "Fedral Tax" << setw(13) << "State Tax" << setw(13) << "Social Security" 
    	  << endl; 
    
    	  outData <<  setw(13) << totalGP << setw(13) << totalNP << setw(13) 
    	  << totalFT << setw(13) << totalST << setw(13) << totalSS
    	  << endl; 
    }
    The input file looks like this:

    1121 15.12 40
    9876 9.50 47
    3333 22.00 35
    2585 12.24 32

    First Row being emplyee numbers, Second Row being Pay Rate and THird Being Hours they worked.

    &#91;code]&#91;/code]tagged by Salem

  6. #6
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    *looks at Halo's post*

  7. #7
    Registered User
    Join Date
    Feb 2002
    Posts
    52

    Question

    lol what is that supposed to mean ? Will you guys help pretty please w/ sugar on top

  8. #8
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    *struggles to speak with noose around neck*

    use...... code...... taaaaaaaaaaags................

  9. #9
    Registered User
    Join Date
    Feb 2002
    Posts
    52
    Hehe use wa wa ? We havn't learned about those yet.... but please help me I need this to run on Borland tommarow. Me being me I thought any compiler is as good as another.... Which I found to be wrong today.

  10. #10
    Registered User
    Join Date
    Feb 2002
    Posts
    52
    So nobody knows whats wrong ?

  11. #11
    Registered User
    Join Date
    Aug 2001
    Posts
    244

    Re: Found my old user Name :-)

    AHHHHHhhhhhhhhhhhhhhhhhhhhhhhh
    *head explodes*


    Code:
    #include<iostream.h>
    #include<fstream.h>
    #include<iomanip.h>
    
    int process_employee(int& empnum, float& emprate, float& emphours, ifstream& inData);
    void process_payroll(ifstream& inData, ofstream& outData, 
    					 const float& FEDERAL_TAX, 
    					 const float& STATE_TAX,
    					 const float& SOCSEC_TAX,
    					 float& totalGP, float& totalNP, float& totalFT, float& totalST,
    					 float& totalSS);
    void print_summary(ofstream& outData, float& totalGP, float& totalNP, 
    				  float& totalFT, float& totalST, float& totalSS);
    
    int main()
    {
    const float FEDERAL_TAX = .15; 
    const float STATE_TAX = .0524;
    const float SOCSEC_TAX = .07;
    
    float totalGP = 0, totalNP = 0, totalFT = 0, totalST = 0, totalSS = 0;
    char flag = ' ';
    int excesshours = 0;
    
    ifstream inData;
    ofstream outData;
    
    inData.open("A:\indata.txt", ios::in);
    outData.open("A:\outdata.txt", ios::out);
    
    process_payroll(inData, outData, FEDERAL_TAX, STATE_TAX, SOCSEC_TAX, totalGP, totalNP,
    				totalFT, totalST, totalSS);
    print_summary(outData, totalGP, totalNP, totalFT, totalST, totalSS);
    
    
    }
    
    int process_employee(int& empnum, float& emprate, float& emphours, ifstream& inData)
    {
      inData >> empnum;
      if(inData.eof()) return 0;
      
      inData >> emprate;
      if(inData.eof()) return 0;
    
      inData >> emphours;
      if(inData.eof()) return 0;
    
      return 1;
    }
    
    void process_payroll(ifstream& inData, ofstream& outData, 
    					 const float& FEDERAL_TAX, 
    					 const float& STATE_TAX,
    					 const float& SOCSEC_TAX,
    					 float& totalGP, float& totalNP, float& totalFT, float& totalST,
    					 float& totalSS)
    {
      int flag = 0;
      int empnum;
      float emprate, emphours, gross, paynet = 0, fed = 0, state = 0, socSec = 0;
      char rateType;
    
      outData << "Employee Payroll\n" << endl;
    
      outData << setw(10) << "Employee" << setw(10) << "Hours" << " " 
    	  << setw(10) << "Rate" << setw(10) << "Gross" << setw(10) << "Net"
           << setw(10) << "Fed"<< setw(10) <<  "State" << setw(10) << "Soc. Sec" << endl;
     
      flag = process_employee(empnum,emprate,emphours,inData);
      while(flag == 1)
      {
    	
    	  gross = (emprate * emphours);
    	  rateType = ' ';
    
    	  //$.15 bonus per hour for employees who work 35 hours or less
    	  if(emphours <= 35)
    	  {
    		  gross +=  .15 * emphours;
    		  rateType = '*';
    	  }
    	  
    	  if(emphours > 40)
    	  {
    		  //add overtime on top of regular wage
    			gross += (emprate * .5) * (emphours - 40);
    			rateType = '$';
    	  }
    
    	  fed = FEDERAL_TAX * gross;
    	  state = STATE_TAX * gross;
    	  socSec = SOCSEC_TAX * gross;
    
    	  paynet = gross - fed - state - socSec;
    
    	  //add up totals
    	  totalGP += gross;
    	  totalNP += paynet;
    	  totalFT += fed;
    	  totalST += state;
    	  totalSS += socSec;
    
    	  //print statements here for individual 
    
    	  outData <<  setw(10) << empnum << setw(10) << emphours << rateType 
    	   << setw(10) << emprate << setw(10) << gross << setw(10) << paynet
           << setw(10) << fed << setw(10) <<  state << setw(10) << socSec << endl; 
    
          flag = process_employee(empnum,emprate,emphours,inData);
    
      }
    }
    		  
    void print_summary(ofstream& outData, float& totalGP, float& totalNP, 
    				  float& totalFT, float& totalST, float& totalSS)
    {
      outData << "Summary-Totals for all employees\n" << endl;
    
      	  outData <<  setw(13) << "Gross Pay" << setw(13) << "Net Pay" << setw(13) 
    	  << "Fedral Tax" << setw(13) << "State Tax" << setw(13) << "Social Security" 
    	  << endl; 
    
    	  outData <<  setw(13) << totalGP << setw(13) << totalNP << setw(13) 
    	  << totalFT << setw(13) << totalST << setw(13) << totalSS
    	  << endl; 
    }

    Easier to read than before! (although the formatting isn't perfect)

    Halo, all I did was put the code between two tags: [ code ] and [ /code ] (without the space after the [ and before the ] )

  12. #12
    Registered User
    Join Date
    Feb 2002
    Posts
    52
    Ahhh thanks man. I always wondered how to make the code tag :-)

    [ code ]
    Testing
    [ /code ]

  13. #13
    Registered User
    Join Date
    Feb 2002
    Posts
    52
    ?

    Okay what did I do wrong ?

    No space in the [] maybe ?

  14. #14
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198
    Yes, no spaces, if he put spaces, then it would have formatted the text into code format, and you wouldnt see what the code tags look like
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  15. #15
    Registered User
    Join Date
    Feb 2002
    Posts
    52
    Okay I got the new it to work in borland and as it turns out my copy of borland was fuxxzored.... Anyhow can someone help me with the set precission command ? I do not know where to put this in the code to show only two decimal places....

Popular pages Recent additions subscribe to a feed