Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

zer0wolf

ANSI C/C++ compliance of gcc

This topic is 5588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I installed the Bloodshed IDE, which came with gcc 3.2, and it won't run a fairly basic C++ program that I know runs in Windows...
#include <iomanip>
#include <ios>
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;

int main()
{
// get the student's name
cout << "Please enter your first name: ";
string name;
cin >> name;
cout << "Hello, " << name << "!" << endl;

// ask for and read the midterm grades
cout << "Please enter your midterm and final exam grades: ";
double midterm, final;
cin >> midterm >> final;

// ask for the homework grades
cout << "Enter all of your homework grades, followed by end-of-file";

// the number and sum of grades so far
int count = 0;
double sum = 0;

// a variable into which to read
double x;

// invariant:
// we have read count grades so far, and sum is the sum of the first count grades
while (cin >> x) {
    ++count;
    sum += x;
}

// write the result
streamsize prec = cout.precision();
cout << "Your final grade is " << setprecision(3)
     << 0.2 * midterm + 0.4 * final + 0.4 * sum / count
     << setprecision(prec) << endl;

return 0;
}
  
It complains about the "string name;" line. WTF is up with this? --------------------------------------------------- laziness is the foundation of efficiency retrospiral.net | llamas! | megatokyo | FreeBSD | gamedev.net | google [edited by - zer0wolf on July 26, 2003 3:48:44 AM]

Share this post


Link to post
Share on other sites
Advertisement
Hmmm... this book sucks...

btw... Thanks guys

EDIT: wow, I feel like such a moron... I should try paying closer attention to the book. It being past 3 in the morning doesn't help much though, I suppose...

---------------------------------------------------
laziness is the foundation of efficiency
retrospiral.net | llamas! | megatokyo | FreeBSD | gamedev.net | google

[edited by - zer0wolf on July 26, 2003 4:00:59 AM]

[edited by - zer0wolf on July 26, 2003 4:06:42 AM]

Share this post


Link to post
Share on other sites
You have now joined the ranks of ''People who go looking for help when the answer is staring them in the face''. Welcome.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!