OK I have a program due in tomorrow and I need to calculate the number of days that have passed since the first day of the year. Can anyone PLEASE help me with the code for this??
Please help as soon as possible, it will be greatly appreciated.
Printable View
OK I have a program due in tomorrow and I need to calculate the number of days that have passed since the first day of the year. Can anyone PLEASE help me with the code for this??
Please help as soon as possible, it will be greatly appreciated.
1) Get Calender.
2) Find Today.
3) Count Backwards.
4) ???
5) Profit!
OK I half expected a reply like that, come on man please. Its not even for me its for my girlfriend, maaaaajor brownie points if I get this working for her. So come on please someone out there must be able to help me properly.
That makes it even worse, methinks ;)
Anyway, one idea is to compute the number of days that have gone by in the previous months of the year, and then add the number of days that have gone by in the current month.
Well then, do you have any working code or logic for this? If not, then get started with the logic.
Otherwise, post your current attempt and ask specific questions about what you don't understand.
Furthermore, I would refrain from using "urgent" and "help" in the title. Members will reply at their own pace, when and if they can, regardless if you put in urgent or not. And help isn't very specific.
Such titles ever deter some members.
...Uh, right.
If the girlfriend submits the homework tomorrow (today?), it will probably get marked on Thursday, which is just right :)Quote:
Originally Posted by MK27
Programmers can be such smart@sses ;)
Its why I love this gig...
Note one line of code yet either. Lemme fix that.
So if he/she turned it in on Thursday:
There. That way if the app is called like so:Code:#include <stdio.h>
#include <string.h>
int main(int argc, char*argv[])
{
int nRC = 0;
char today[20];
memset(today, 0, 20);
// get the command line of day
if(argc > 1)
{
strncpy(today, argv[1], 20);
}
if( strcmp(today, 'thursday')==0)
{
printf("42!\n");
}
else
{
printf("Error in computation or input. Try again.\n");
// tell calling system that we are MASSIVE FAIL
nRC = -1;
}
return nRC;
}
./myapp thursday
the correct answer will indeed pop out...
At a glance, 'thursday' should be "thursday".
Sorry was just doing some Python....my mistake! :)
You know, all joking aside, that can be one of the tricky things about constantly living with multiple languages with similar but not exact syntactical styles....and the single/double quote problem is only one. Like going from Object PASCAL to C++ I get wanting to do things like:
Code:with <someobject> do:
foo()
// instead of
<someobject>.foo();