•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 426,905 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,338 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 2282 | Replies: 4
![]() |
•
•
Join Date: Dec 2004
Posts: 11
Reputation:
Rep Power: 4
Solved Threads: 0
Hello there,
Okay i had to write a program that computes the number of days between two dates, right, and so far i'm just sort of stumped over what to do next to get it all right and functioning correctly. I've written the code and everything else, and It runs, but the awnsers not what i'm looking for. Maybe someone can tell me what i'm not doing that i need to be doing. Well i would appreciate your help.
Here's my source code:
Okay i had to write a program that computes the number of days between two dates, right, and so far i'm just sort of stumped over what to do next to get it all right and functioning correctly. I've written the code and everything else, and It runs, but the awnsers not what i'm looking for. Maybe someone can tell me what i'm not doing that i need to be doing. Well i would appreciate your help.
Here's my source code:
// Program 7
// This program computes the number of days between two dates.
#include <iostream>
using namespace std;
int DayCalculation (int month, int day, int year, int month2, int day2, int year2);
int main()
{
int month;
int secondMonth;
int year;
int day;
int secondYear;
int secondDay;
cout << "Enter first dates month ";
cin >> month;
cout << "Enter second dates month ";
cin >> secondMonth;
cout << "Enter the first dates day ";
cin >> day;
cout << "Enter the second dates day ";
cin >> secondDay;
cout << "Enter the first dates year ";
cin >> year;
cout << "Enter the second dates year ";
cin >> secondYear;
if (month >= 10 && day >= 15 && year >= 1582)
cout << "The date you entered is invalid";
else
DayCalculation ( month, day, year, secondMonth, secondDay,secondYear);
return 0;
}
int DayCalculation ( int month, int day, int year, int month2, int day2, int year2)
{
int result1 = 0;
int result2;
int result3;
long JulianDayNumber;
if (month == 1 || month == 2 )
{
year--;
month = month +12;
}
result1 = 2- year/100+year / 400; // test each one to make sure the right number.
result2 = int(365.25 * year);
result3 = int(30.6001 * (month + 1));
JulianDayNumber = result1 + result2 + result3 + day + 1720994.5;
cout << JulianDayNumber << endl;
return 0;
}•
•
Join Date: Dec 2004
Location: galveston, texas
Posts: 35
Reputation:
Rep Power: 4
Solved Threads: 1
•
•
•
•
Originally Posted by jtxay
...and It runs, but the awnsers not what i'm looking for.
gcc -o dates dates.cpp dates.cpp: In function `int DayCalculation(int, int, int, int, int, int)': dates.cpp:67: warning: converting to `long int' from `double' /tmp/ccLb60he.o(.text+0x1b): In function `main': : undefined reference to `std::cout' /tmp/ccLb60he.o(.text+0x20): In function `main': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /tmp/ccLb60he.o(.text+0x2e): In function `main': : undefined reference to `std::cin' /tmp/ccLb60he.o(.text+0x33): In function `main': : undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)' /tmp/ccLb60he.o(.text+0x42): In function `main': : undefined reference to `std::cout' /tmp/ccLb60he.o(.text+0x47): In function `main': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /tmp/ccLb60he.o(.text+0x55): In function `main': : undefined reference to `std::cin' /tmp/ccLb60he.o(.text+0x5a): In function `main': : undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)' /tmp/ccLb60he.o(.text+0x69): In function `main': : undefined reference to `std::cout' /tmp/ccLb60he.o(.text+0x6e): In function `main': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, ...... Compilation exited abnormally with code 1 at Wed Dec 8 18:28:49
•
•
Join Date: Dec 2004
Location: galveston, texas
Posts: 35
Reputation:
Rep Power: 4
Solved Threads: 1
just a thought but have you thought using a windows calendar control? it will take into account leap years and will do the calcuations for you...?
for gcc, change <iostream> to <iostream.h> and remove the namespace statement, it might fix errors....
for gcc, change <iostream> to <iostream.h> and remove the namespace statement, it might fix errors....
http://sales.carina-e.com
no www
no nonsense
coming soon to a pc near you! :cool:
no www
no nonsense
coming soon to a pc near you! :cool:
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- help: code block for writing audio cd (C++)
- printing double array formatting trouble (C)
- securing code on a webserver (Java)
- Trouble writing code for arithmetic calculations of complex numbers (C++)
- Odd/Even Code (Java)
- HELP with the SYSTEM FILES FOR WINDOWS ! (C++)
Other Threads in the C++ Forum
- Previous Thread: confused loops
- Next Thread: need help with this error


Linear Mode