|  |
01-08-2006, 03:11 PM
|
#1 (permalink)
|
Ultra Techie Join Date: Jun 2004 Location: Minnesota Posts: 962
| Another C++ program error Alright I have another program that has been created out of a few different source files. The problem I get is when I try to create a while loop in one of these source files the program will not work, but when I don't use the while loop, the program works, but then it goes into a continuous loop of displaying what I want the user to enter. It's starting to boggle my mind and I can't figure it out. Any help is appreciated. Thanks in advance.
__________________ Desktop: Core 2 Duo E6600 @ 2.4, Asus P5B-E, 3GB G. Skill DDR2 800, eVGA 8800GT Superclocked 512MB, 22" LG, 19" NEC
Laptop: HP Pavilion dv9500, Core 2 Duo T7300 @ 2.0, 3GB G. Skill DDR2 667, nVidia 8600 M GS 512MB, 17" |
| |
01-09-2006, 12:33 AM
|
#2 (permalink)
|
Ultra Techie Join Date: Jun 2004 Location: Minnesota Posts: 962
| Can anyone help me?
__________________ Desktop: Core 2 Duo E6600 @ 2.4, Asus P5B-E, 3GB G. Skill DDR2 800, eVGA 8800GT Superclocked 512MB, 22" LG, 19" NEC
Laptop: HP Pavilion dv9500, Core 2 Duo T7300 @ 2.0, 3GB G. Skill DDR2 667, nVidia 8600 M GS 512MB, 17" |
| |
01-09-2006, 12:50 AM
|
#3 (permalink)
|
Ultra Techie Join Date: Jun 2004 Location: Minnesota Posts: 962
| void GetDate (int&, int&, int&)
{
//Variables
int day, month, year;
//Explain program to user
cout << "This program will output the day of the week for any ";
cout << "given day." << endl;
cout << "Input in the form as month/day/year. ctrl d ends the ";
cout << "program. ";
cin >> month >> day >> year;
while (!cin.eof())
{
cin >> month >> day >> year;
}
}
Here is the code I'm having trouble with. When I get ride of the while loop I get a continuous loop, although when I have the while loop in, the program won't output anything. I have narrowed the mistake down to this source code and I can't figure it out. ANY HELP AT ALL is appreciated.
__________________ Desktop: Core 2 Duo E6600 @ 2.4, Asus P5B-E, 3GB G. Skill DDR2 800, eVGA 8800GT Superclocked 512MB, 22" LG, 19" NEC
Laptop: HP Pavilion dv9500, Core 2 Duo T7300 @ 2.0, 3GB G. Skill DDR2 667, nVidia 8600 M GS 512MB, 17" |
| |
01-09-2006, 03:01 PM
|
#4 (permalink)
|
Ultra Techie Join Date: Jun 2004 Location: Minnesota Posts: 962
| Alright, here is the main function.
#include <iostream>
using namespace std;
void GetDate(int& month, int& day, int& year);
int DayOfWeek(int month,int day,int year);
void OutputDay(int dayofweek);
int main()
{
int day, month, year;
int dayofweek;
GetDate(month,day,year);
while (!cin.eof())
{
dayofweek = DayOfWeek(month,day,year);
OutputDay(dayofweek);
GetDate(month,day,year);
}
cout << endl;
return 0;
}
If anyone can help me figure out why this is in a continuous loop. I also removed the while loop on the GetDate function.
__________________ Desktop: Core 2 Duo E6600 @ 2.4, Asus P5B-E, 3GB G. Skill DDR2 800, eVGA 8800GT Superclocked 512MB, 22" LG, 19" NEC
Laptop: HP Pavilion dv9500, Core 2 Duo T7300 @ 2.0, 3GB G. Skill DDR2 667, nVidia 8600 M GS 512MB, 17" |
| |  | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | |