| | |
Having a little trouble with my Code. [please Help me out]
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2004
Posts: 11
Reputation:
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:
C++ Syntax (Toggle Plain Text)
// 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; }
•
•
•
•
Originally Posted by jtxay
...and It runs, but the awnsers not what i'm looking for.
C++ Syntax (Toggle Plain Text)
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
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:
![]() |
Similar Threads
- Trouble getting code to compile (C++)
- Pls help with C code. Evaluating data types. (C)
- trouble with c++ code (C++)
Other Threads in the C++ Forum
- Previous Thread: confused loops
- Next Thread: need help with this error
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray email encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library linker list loop looping loops map math matrix memory microsoft newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets





