#include <iostream.h>
#include <stdlib.h>
// kijkt hoeveel dagen er verstreken zijn; sinds maandag 01-01-1900
// dag = de dag (van de maand)
// maand = de maand (in nummers)
// jaar = het jaar (4 cijfers)
// returns: hoeveel dagen er verstreken zijn
int verstreken(int dag, int maand, int jaar)
{
int myDagen_2;
int myDagen_1 = dag;
if (maand == 1)
{
myDagen_2 = 0;
}
elseif (maand == 2)
{
myDagen_2 = 31;
}
elseif (maand == 3)
{
myDagen_2 = 59;
}
elseif (maand == 4)
{
myDagen_2 = 90;
}
elseif (maand == 5)
{
myDagen_2 = 120;
}
elseif (maand == 6)
{
myDagen_2 = 151;
}
elseif (maand == 7)
{
myDagen_2 = 181;
}
elseif (maand == 8)
{
myDagen_2 = 212;
}
elseif (maand == 9)
{
myDagen_2 = 243;
}
elseif (maand == 10)
{
myDagen_2 = 273;
}
elseif (maand == 11)
{
myDagen_2 = 304;
}
elseif (maand == 12)
{
myDagen_2 = 334;
}
int myJaarVoorbij = jaar - 1900;
int myDagen_3 = myJaarVoorbij * 365;
if (maand < 1 && dag < 28)
{
myDagen_3 = myDagen_3 + myJaarVoorbij / 4;
}
int myDagen = myDagen_1 + myDagen_2 + myDagen_3 - 1;
return myDagen;
}
//kijkt welke dag van de week het is
//verstreken = het aantal dagen dat verstreken is sinds 1 jan. 1900 (maandag)
//returns = maandag, dinsdag, woensdag, donderdag, vrijdag, zaterdag, zondag
string Weekdag(int verstreken)
{
verstreken %= 7;
int myWeekdag;
if (verstreken == 0)
{
myWeekdag = "maandag";
}
if (verstreken == 1)
{
myWeekdag = "dinsdag";
}
if (verstreken == 2)
{
myWeekdag = "woensdag";
}
if (verstreken == 3)
{
myWeekdag = "donderdag";
}
if (verstreken == 4)
{
myWeekdag = "vrijdag";
}
if (verstreken == 5)
{
myWeekdag = "zaterdag";
}
if (verstreken == 6)
{
myWeekdag = "zondag";
}
return myWeekdag;
}
//het programma zelf
int main()
{
cout << "op 28 feb 1904 zijn er " << verstreken(28, 2, 1904) << " dagen verstreken sinds 1 januari 1900." << endl << "Het is dan een " << weekdag(verstreken(28, 2, 1904)) << "." << endl;
system("PAUSE");
return 0;
}
this are the errors:
syntax error before '(' // line 72
parse error before 'if' // line 76
implicit declaration of function 'int weekdag(...)' // line 109
I don't see that you declared "Weekdag" in the header area.
line 72: don't know.
line 76: What's a parse error? Don't know.
EDIT IN RESPONSE TO simpleasy Jul 4, 2008 at 6:56am: Yes, simpleasy, you used the function "Weekdag" from lines 72-105, but you failed to declare it anywhere. You MUST have a declaration for a function, unless it is your main() function.
the line 72 error may be that, and I am not really sure, a function fo type string may not be declared? Try "char weekdag"
The lien 76 error seems to be a logical follow up on the weekdag-function error.
there are 7 errors, always at the return-line, and the last error stays the same, but if the other 7 are solved, that one will work to i gues..
so, here are the 7 important errors:
line 78: assignment to 'int' from 'const char*' lacks a cast
line 82: assignment to 'int' from 'const char*' lacks a cast
line 86: assignment to 'int' from 'const char*' lacks a cast
line 90: assignment to 'int' from 'const char*' lacks a cast
line 94: assignment to 'int' from 'const char*' lacks a cast
line 98: assignment to 'int' from 'const char*' lacks a cast
line 102: assignment to 'int' from 'const char*' lacks a cast
great! it works
but could you please explain why there sometimes have to stand 'std::' before something?
and where can i find some explaination of al the includestuff? beacouse i don't get the point of it :P
The standard C++ library has its elements defined in the Namespace[1] called std, to resolve the name of an element in your code you use the namespace name followed by the resolution operator :: eg std::cout, you could also put usingnamespace std; just after the #includes section this will allow you to use the elements of the namespace without using std:: in front of it.