Hi ladies and gents,

I wanted to start a new exercise, but after reading it several times, I actually don't know what the exercise is all about :!:

The translation into English is this:

Write a function wich can be declarered as the following:

unsigned int datecode(int year, int month, int day);

The task of this function is to encode the given date into the 16 bits(the 16 right bits) of the unsigned int and deliver that as a function value. From left to right we get:

7 bits for the last two numbers of the year (<=99),

4 bits for the month (<=12)

5 bits for the day (<= 31)Keep in account that the parameter (year) can be entered as (99) or (1999)!

Now, at first I tought that I could use the codebits wich where written by Vegaseat and Dave Sinkula, but after looking at it, it's obvious that's not the case since they do use pointers and strings :-|

Since I have to use the declaration: unsigned int datecode (int year, int month, int day);

The example of them can't be used :!:

Before I realised this, I did make this piece of code, using a huge part of Vegaseat Code Snippet: http://www.daniweb.com/code/snippet87.html

I tried to do this exercise starting with one parameter for the day wich resulted into this:

```
unsigned int datecode (int day);
int main()
{
int day = 3, value;
value = datecode (day);
cout<< "The coded value equales: " << value <<endl;
cin.get();
return 0;
}
unsigned int datecode (int day)
{
int remain = 0, k = 0, n = 0;
int temp[80], value[80];
do
{
remain = day % 2;
day = day / 2; // whittle down decimal
temp[k++] = remain + 0x30; // makes characters 0 or 1
}
while (day > 0);
while (k >= 0)
{
value[n++] = temp[--k]; // reverse spelling
}
value[n-1] = 0;
return value[n];
}
```

Problem with this code is:

1) The returned value isn't a piece of binary code, it's just rubbish! This because I can't use a pointer wich would contain the value of the binary code as in the original code by Vegaseat!

So, to recap a bit, my questions are:

1) Do you understand what the idea is for this exercise when reading the task?

2) If so, could you give an example of what is meant by it?

Thanks for the assistance in advance ;)