Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Problem with manipulators between compilers.

indigo0086indigo0086 Member Posts: 2
I did a little program that uses ofstream and the manipulators: fixed, showpoint, left, and right. The program compiles perfectly in Visual C++ but not in DevC++. I e-mailed the developer of the compiler and the manipulators are not ANSII standard. I think the book just assumes you have Visual C++ or something, but I need to know the ANSII standard equivalent to those manips. here is the program I wrote..
-----------------------------------------------------------------------
#include
#include
#include

using namespace std;
const double propTaxCal = 0.92;
const double taxRate = 1.05;

int main()

{
double assessedVal, taxAmount, propertyTax;


ofstream outFile;
outFile.open("a:ch3_Ex4out.txt");
cout << "This Program will help you Calculate property tax

";
cout << "Enter the Assesed value of the Property:
";
cin >> assessedVal;
cout << "Calculating values to output file on Drive A";

outFile << fixed <<showpoint << setprecision(2);

taxAmount = assessedVal * propTaxCal;

outFile <<left <<"Assesse Value:" <<setw(34) <<setfill('.') <<right <<assessedVal << endl;
outFile <<left <<"TaxAmount:"<<setw(38) <<setfill('.') <<right <<taxAmount << endl;
outFile <<left <<"Tax Rate for each $100.00:"<<setw(22) <<setfill('.') <<right <<"1.05" << endl;

propertyTax = (taxAmount / 100) * taxRate;

outFile <<left <<"Property Tax: " <<setw(34) <<setfill('.') <<right << propertyTax <<endl;



return 0;
}

Comments

  • DariusDarius Member Posts: 1,666
    [b][red]This message was edited by Darius at 2002-9-25 5:3:4[/red][/b][hr]
    : I did a little program that uses ofstream and the manipulators: fixed, showpoint, left, and right. The program compiles perfectly in Visual C++ but not in DevC++. I e-mailed the developer of the compiler and the manipulators are not ANSII standard. I think the book just assumes you have Visual C++ or something, but I need to know the ANSII standard equivalent to those manips. here is the program I wrote..

    Those manipulators ARE Standard. However, if you thought they weren't, then WHY would you bother the compiler developer?

    Your code however IS non-standard. The header files iostream.h, fstream.h and iomanip.h are non-standard. The CORRECT files are iostream, fstream, iomanip (i.e. NO .h). That may or may not fix your problem. Next time you have a compilation error do two things, 1) don't harass the developer of the compiler unless you REALLY know what you are talking about and are SURE it's a problem of the compiler (and preferably after looking at the sourcecode and developing a patch to fix the problem if you can manage it), and b) POST the error messages you get.

    In this case, the compiler is the GNU C/C++ compiler, which is NOT maintained by DevC++, ported to Windows via Mingw, which is NOT maintained by DevC++ or the GCC developers, using the libstdc++ library (probably if you have a current version of GCC), which is ALSO NOT maintained by DevC++ or the GCC developers or the Mingw developers. Finally, GCC is probably the MOST standards compliant C++ compiler out there, meaning that the only way your code could not work is if your code was non-standard, in which case it's definitely NOT the compiler writers fault that your code doesn't work. Okay, I guess I will concede that there is some slight possibility that you've managed to find a compiler flaw with this trivial code that no one else has had and that foiled the battery of tests GCC compilers are put through after they are built.


  • abcabc Member Posts: 443
    : I did a little program that uses ofstream and the manipulators: fixed, showpoint, left, and right. The program compiles perfectly in Visual C++ but not in DevC++. I e-mailed the developer of the compiler and the manipulators are not ANSII standard. I think the book just assumes you have Visual C++ or something, but I need to know the ANSII standard equivalent to those manips. here is the program I wrote..
    :

    those manipulators are declared in ios_base, so the way to access them is [red]ios::[/red]fixed [red]ios::[/red]showpoint and so on.
  • Chris BrownChris Brown USAMember Posts: 4,496 ✭✭

    ________ < http://forcoder.org /> free video tutorials and ebooks about | Scratch Python C++ Delphi R Swift Visual Basic Java Visual Basic .NET Assembly Go Perl MATLAB C# Objective-C C Ruby PL/SQL PHP JavaScript ML Kotlin Scala Hack Dart Erlang Transact-SQL VBScript D Bash Awk Clojure Alice Logo LabVIEW Fortran SAS Julia Prolog ABAP COBOL FoxPro F# Apex Lua Scheme Rust Lisp Crystal Ada | ____________

Sign In or Register to comment.