Board index » cppbuilder » is there something wrong?

is there something wrong?


2004-02-24 09:53:42 AM
cppbuilder66
int main(int argc, char* argv[])
{
std::cout << "how many pennies do you have?\n";
int pennies;
std::cin>>pennies; /* input pennies */
std::cout << "how many nickels do you have?\n";
int nickels;
std::cin>>nickels; /* input nickels */
std::cout << "how many dimes do you have?\n";
int dimes;
std::cin>>dimes; /* input dimes */
std::cout << "how many quarters do you have?\n";
int quarters;
std::cin>>quarters; /*input quarters */
double total = pennies * 0.01 + nickels * 0.05 +
dimes * 0.10 + quarters * 0.25; /* total number of coins */
std::cout << "total value = " << total << "\n";
return 0;
}
when i try to compile this program the c++ builder 6 states that it cannot open # include <oldstl/locale.h>. is there something missing ?
 
 

Re:is there something wrong?

"ricky sovanasy" < XXXX@XXXXX.COM >wrote in message
Quote
when i try to compile this program the c++ builder 6 states that
it cannot open # include <oldstl/locale.h>. is there something missing ?
You have not shown enough of your code to see if you are misusing the header
files, and you have not stated how your include paths are set up in the
project options.
Gambit
 

Re:is there something wrong?

make sure you
#include <iostream>
#include <stdlib>
I think from what you have everything should compile if you include these
two files in your .cpp file
 

{smallsort}

Re:is there something wrong?

JunkMail wrote:
Quote
#include <stdlib>
should be
#include <cstdlib>
Michel
--
----------------------------------------
Michel Leunen
mailto: see my homepage.
C++Builder, C++BuilderX, BCC5.5.1 Web site:
www.leunen.com/
----------------------------------------
 

Re:is there something wrong?

"JunkMail" < XXXX@XXXXX.COM >writes:
Quote
make sure you

#include <iostream>
#include <stdlib>
<istream>and <ostream>are also required to make sure the the operators>>
and << for char * resp. char const * are declared. Otherwise, those for
void *& resp. void const * might be used.
 

Re:is there something wrong?

"ricky sovanasy" < XXXX@XXXXX.COM >writes:
Quote
int main(int argc, char* argv[])
{
std::cout << "how many pennies do you have?\n";
int pennies;
std::cin>>pennies; /* input pennies */

std::cout << "how many nickels do you have?\n";
int nickels;
std::cin>>nickels; /* input nickels */

std::cout << "how many dimes do you have?\n";
int dimes;
std::cin>>dimes; /* input dimes */

std::cout << "how many quarters do you have?\n";
int quarters;
std::cin>>quarters; /*input quarters */

double total = pennies * 0.01 + nickels * 0.05 +
dimes * 0.10 + quarters * 0.25; /* total number of coins */
Apart from the good response you have already received, please note that
each of the above input and output operations may fail. This means
that you could end up with some of the variables uninitialized. Reading
uninitialized variables causes your program to have undefined behavior.
So better check the success of (at least) each input operation before
blindly going on, e.g.:
if (std::cin>>pennies)
; // success - go on
else
; // handle error