sstream

B

bpazolli

Quick noob question. I have dev-C++ 4 doing a tutorial. Typed in
#include <sstream> and get file does not exist.

Thanks,
Ben Pazolli
 
M

mlimber

bpazolli said:
Quick noob question. I have dev-C++ 4 doing a tutorial. Typed in
#include <sstream> and get file does not exist.

In decreasing order of likelihood, you either typed something
incorrectly (per FAQ 4.8, cut and paste your exact code here), your
environment is not set up properly to find the include file (seek help
in a forum dedicated to your platform), or your platform does not have
a standard-conforming C++ library currently installed (install a
complete development package or download STLport or similar).

Cheers! --M
 
B

bpazolli

In decreasing order of likelihood, you either typed something
incorrectly (per FAQ 4.8, cut and paste your exact code here), your
environment is not set up properly to find the include file (seek help
in a forum dedicated to your platform), or your platform does not have
a standard-conforming C++ library currently installed (install a
complete development package or download STLport or similar).

I downloaded some source files for Dev-C++ for another tutorial using
sstream and it also didn't compile correctly, so it probably isn't a
mistype. I suspect I don't have the environment set up properly as I
did a typical install of Dev-C++ 4. None the less, here is my entire
code, just a tutorial so it does very little in a long winded way, I
want to know how to make it work this way though, not how I could do it
in one line another way.

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
string mystr;
float price = 0;
int quantity = 0;

cout << "Enter price: ";
getline (cin,mystr);
stringstream(mystr) >> price;
cout << "Enter quantitiy: ";
getline (cin,mystr);
stringstream(mystr) >> quantity;
cout << "Total price: " << price*quantity << endl;
return 0;
}

Thanks,
Ben Pazolli
 
M

mlimber

bpazolli said:
I downloaded some source files for Dev-C++ for another tutorial using
sstream and it also didn't compile correctly, so it probably isn't a
mistype. I suspect I don't have the environment set up properly as I
did a typical install of Dev-C++ 4. None the less, here is my entire
code, just a tutorial so it does very little in a long winded way, I
want to know how to make it work this way though, not how I could do it
in one line another way.

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
string mystr;
float price = 0;
int quantity = 0;

cout << "Enter price: ";
getline (cin,mystr);
stringstream(mystr) >> price;
cout << "Enter quantitiy: ";
getline (cin,mystr);
stringstream(mystr) >> quantity;
cout << "Total price: " << price*quantity << endl;
return 0;
}

This builds fine at <http://dinkumware.com/exam>, so I expect it is a
problem with your installation or configuration.

Cheers! --M
 
B

bpazolli

I read the almost exact same problem on another forum. I think the only
answer is to upgrade to beta version 5. I'm not interested in that, so
instead I downloaded a borland free command line compiler from their
site, version 5.5, and it worked great. I created a batch file, now all
I type in is bcc main.cpp, and it creates the exe. Simple. IDEs just
complicate things at this level.

Thanks for the Help,
Ben Pazolli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top