ios_base::precision



This doesn't seem to work for me:
http://www.cplusplus.com/reference/iostream/ios_base/precision/

21 C:\Users\Joanne Perez\Desktop\yes.cpp initializing argument 1 of `std::_Ios_Fmtflags std::ios_base::setf(std::_Ios_Fmtflags, std::_Ios_Fmtflags)'
^ that's what my compiler said after reading
this: cout.setf(0, ios::floatfield);

what should I do? Is there an alternative or something?
can we see your code??
#include <iostream>
using namespace std;

int main(){

double input;
char check;

cout << "Input 's' to convert from scientific notation to decimal." << endl;
cout << "Input 'd' to convert from decimal to scientific notation: ";
cin >> check;

if (check == 's'){

cout << "Please enter the scientific notation: " << endl;
cout << "eg: 1.0e-10";
cin >> input;

cout << "Scientific notation: ";
cout << scientific << input << endl;
cout.setf(0, ios::floatfield);
cout.precision(10);
cout << "Decimal: " << input << endl;
}
if (check == 'd){

cout << "Please enter the decimal: ";
cin >> input;
cout << "Decimal: " << input << endl;
cout << "Scientific notation: ";
cout << scientific << input << endl;
}

return 0;
}
Topic archived. No new replies allowed.