iccaros Posted April 5, 2005 Report Share Posted April 5, 2005 jcl, you said "cstdlib' contains the declaration of system()"but in my program// This is a test program#include <iostream>#include <iomanip>using namespae std;int main (){ init grade, total, gradeCounter; double average; system ("clear"); cout << "Enter Grade or -1 to finish"; cin >> gradewhile ( grade != -1) { total += grade; ++gradeCounter;}if ( grade != -1) { average = static_cast< double> (total) / gradeCounter; if ( average >= 60) cout << "you pass!! with a grade point average of: " << average << endl; else cout << " You Failed!! with a Grade point average of: " << average << endl;}else cout << "You did not enter any Grades!!!!" << endl;return 0;}you will see I did not add this.. why does it still work.. does gcc add the correct libs when I don't? Quote Link to post Share on other sites
iccaros Posted April 5, 2005 Author Report Share Posted April 5, 2005 // This is a test program#include <iostream>#include <iomanip>using namespace std;int main (){ int grade, total, gradeCounter; double average; total = 0; gradeCounter = 0; system ("clear"); cout << "Enter Grade or -1 to finish "; cin >> grade;while ( grade != -1) { total += grade; ++gradeCounter; cout << "Enter Grade or -1 to finish "; cin >> grade;}if ( grade != -1) { average = static_cast< double > ( total ) / gradeCounter; if ( average >= 60 ) cout << "you pass!! with a grade point average of: " << average << setprecision( 2 ) << fixed << endl; else cout << " You Failed!! with a Grade point average of: " << average << setprecision( 2 ) << fixed << endl;}else cout << "You did not enter any Grades!!!!" << endl;return 0;}ok this is not working no matter what I enter I get "you did not enter any grades???" Quote Link to post Share on other sites
iccaros Posted April 5, 2005 Author Report Share Posted April 5, 2005 so stupid.. my if should check gradeCounter not grade... man this language makes me feel stupid.. Quote Link to post Share on other sites
jcl Posted April 6, 2005 Report Share Posted April 6, 2005 (edited) jcl, you said "cstdlib' contains the declaration of system()"It looks like the iostream header indirectly pulls in cstdlib. It's not portable behavior as far as I know.man this language makes me feel stupid..Not an uncommon problem. Wait till you get into templates. Sometimes I can't believe people use C++ at all. Edited April 6, 2005 by jcl Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.