Tom Gunn 1,164 Practically a Master Poster

Yes, null bytes with a value of 0x00 are used as padding for alignment purposes.

Tom Gunn 1,164 Practically a Master Poster

hw can i make x and y give me the lowest form of the rational numbers

Do you mean you want to reduce a fraction?

HERE: scanf("%d", &v);
if(v==0)
{
printf("Don't use 0 \n");
goto HERE;
}

HERE is a terrible name for a goto label. But a jump does not buy you anything here. A loop is much clearer:

while (scanf("%d", &v) != 1 || v == 0)
{
    printf("Invalid entry. Try again: ");
}
Tom Gunn 1,164 Practically a Master Poster

1. Whether I can use ASCII code for to print special symbols, like I have done above in 3 cases.

What are special characters? Are they the glyph characters that are neither digits nor latin alphabet characters? Are they control characters? What about extended characters? All of the above? You need to specify what you think a special character is before you can test for one.

2. Are there braces missing in my program after if statement.

That is something your compiler will tell you. :)

3. Can I test this program online.

I do not know of a way to compile and run a program online, but you can compile your code here. Be sure to set it to compile as C though. It defaults to C++.

This code is specific to the ASCII character set. It would not work with other character sets.

Which ones? The only one I know of is EBCDIC, and EBCDIC is not common. Everything else that supports the latin characters is compatible with 7 bit ASCII, AFAIK.

For readability I would use character constants instead of straight values:

if (ch >= 'A' && ch <= 'Z')
{
    printf("The character is uppercase\n");
}
else if (ch >= 'a' && ch >= 'z')
{
    printf("The character is lowercase\n");
}
else if (ch >= '0' && ch <= '9')
{
    printf("You entered a digit\n");
}

It is a safe assumption that this is a homework assignment and the is*() …

Tom Gunn 1,164 Practically a Master Poster

Are you using the <string> header?

System::String is not the same as std::string . The former is the .NET framework's string class that is used in C++/CLI code.

I have trolled the interwebz looking for an answer and can't find anything helpful.

Your question is a Microsoft knowledge base article. It came up as the first hit when searching Google for your thread title.

Tom Gunn 1,164 Practically a Master Poster

A stringstream is still a stream, and stream objects in C++ do not have copy semantics. You can make that field a reference or a pointer if the stringstream is a necessary instance variable. Or you can recreate the stream each time you need it, but that would depend on what you are using the stream for.

necrolin commented: You're a life saver. Thank you. +1
Tom Gunn 1,164 Practically a Master Poster

Funny Tom you gave me negative feedback yesterday for helping someone with a SIMPLE piece of code...but its ok for you to do it?

I think the difference is clear if you read the questions. The OP you answered was asking for someone to do it for him. This one is actually trying and not making the connection that I showed to be important. But I did solve the problem completely in C++. Pseudo code would have been better, so I will accept your down vote in the spirit it was given. Thank you for keeping me honest. :)

p.s. For what it is worth, I did not test the code, so it might not even compile. ;)

Tom Gunn 1,164 Practically a Master Poster

Can you post the definition of the Client class? It looks like the problem is a field that does not have copy semantics, and the vector class requires those semantics.

Tom Gunn 1,164 Practically a Master Poster

Can anyone help me with the algorithm for the height of a n-ary tree, I have been looking and could only found for a binary tree

The basic algorithm is the same. The only difference is that instead of just following the left and right links, you follow n links. Here is the algorithm for a binary tree:

int Height(Node* root)
{
    if (!root) return -1;

    int lh = Height(root->left);
    int rh = Height(root->right);

    return 1 + std::max(lh, rh);
}

For an n-ary tree, the only difference is replacing the two heights with n heights:

int Height(Node* root)
{
    if (!root) return -1;

    std::set<int> heights;

    for (int x = 0; x < N; ++x)
    {
        heights.insert(Height(root->link[x]));
    }

    return 1 + *heights.rbegin();
}
Unix* commented: like you said, yo shouldn post the answers +0
Tom Gunn 1,164 Practically a Master Poster

But is there anyway to apply this to a class?

It depends on what you mean, but until you correct me I will assume you mean an array of class objects. :) If the class is already defined then it is a usable type just like int:

// myarray.h
#if !defined(MYARRAY_H)
#define MYARRAY_H
#include "myclass.h"

#define MYARRAY_SZ 100

extern MyClass myarray[];

#endif
// myarray.cpp
#include "myarray.h"
#include "myclass.h"

MyClass myarray[MYARRAY_SZ];

As long as the class has a default constructor you can create an array like that. Alternatively you can use just a forward declaration of the class in the header file and define it in the implementation file:

// myarray.h
#if !defined(MYARRAY_H)
#define MYARRAY_H

#define MYARRAY_SZ 100

class MyClass;

extern MyClass myarray[];

#endif
// myarray.cpp
#include "myarray.h"
#include "myclass.h"

MyClass myarray[MYARRAY_SZ];
Tom Gunn 1,164 Practically a Master Poster

const just says the function will not change anything

Kind of. const can only be applied to methods, and it means two things:

  1. The immutable state of the object will not be changed within a const method.
  2. The const method can be called by objects that are declared as const.

The mutable keyword was introduced to allow mutable data for const objects. The idea is that mutable data does not contribute to the constness state of the object. Mutable fields can be modified in a const method. Here is a sample program that displays the concept of const methods and mutable fields:

class Test
{
    int _x;
    mutable int _y;
public:
    Test(int x, int y): _x(x), _y(y) {}

    void Method1()
    {
        _x = 0; // OK, _x is mutable in a non-const method
        _y = 0; // OK, _y is mutable in all cases
    }

    void Method2() const
    {
        _x = 0; // will not compile, _x is immmutable in a const method
        _y = 0; // OK, _y is mutable in all cases
    }
};

int main()
{
    Test a(1, 2);
    Test const b(1, 2);

    a.Method1(); // OK, non-const object calling non-const method
    a.Method2(); // OK, non-const object calling const method
    b.Method1(); // will not compile, b is const, but Method1() is not
    b.Method2(); // OK, b is const and Method2() is const
}
Tom Gunn 1,164 Practically a Master Poster

Traditionally it is done with a header file and an implementation file:

// myarray.h
#if !defined(MYARRAY_H)
#define MYARRAY_H

#define MYARRAY_SZ 100

extern int myarray[];

#endif
// myarray.cpp
#include "myarray.h"

int myarray[MYARRAY_SZ];
// main.c
#include <iostream>
#include "myarray.h"

int main()
{
    for (int x = 0; x < MYARRAY_SZ; ++x) myarray[x] = x;
    for (int x = 0; x < MYARRAY_SZ; ++x) std::cout << myarray[x] << '\n';
}

The header file declares a name so that multiple modules can use it without getting repeated definition errors, and the implementation file provides the single definition.

Tom Gunn 1,164 Practically a Master Poster

What do you mean by "it's not working"? Are you getting a compile time error? A run time error? "It's not working" is not a helpful description of the problem.

Tom Gunn 1,164 Practically a Master Poster

First of all, how different is your method from P/Invoke, which is also used to call functions in dll's.

P/Invoke is a way to access unmanaged COM DLLs from managed code. The implicit and explicit linking you read about in the tutorial were strictly unmanaged methods. The only way you can use P/Invoke, AFAIK, is to jump into C++/CLI, which is technically a different language from standard C++.

what if some functions are not exported.... will I still be able to use them?

Officially, as good little programmers we are not allowed to use functions that were not exported. Unofficially, we can do anything well damn well please given sufficient knowledge of the file formats. But circumventing the rules is tricky and complex. For example, signature scanning is one way to find and use functions that are not part of the export table in a DLL or executable.

There are lots of reasons why you do not want to do that. First and foremost is versioning. Unexported functions are not bound by the interface and can change or go away entirely between versions of a DLL. It is the same as circumventing the access restrictions in C++ to get at a class' private methods.

Tom Gunn 1,164 Practically a Master Poster

No, next_permutation won't work because his desired output is out of order :)

OK, store it in a vector and use random_shuffle(). :D

Tom Gunn 1,164 Practically a Master Poster

Cool! OK then scratch that request but keep the other one unless there is a cool and too obvious way to do that too. ;)

Tom Gunn 1,164 Practically a Master Poster

On the right hand side of every page is a box titled My Favorite Forums. I can see which forums have new posts and which do not. But I would also like to be able to mark just those forums as read, and I would like to know how long ago the last post was without looking at the big forum list.

On the big forum list it tells me that on the IT Professionals' Lounge forum the last post was 1 hour ago and there are 49 people viewing it. That kind of information would be nice on the favorite forums list too.

Tom Gunn 1,164 Practically a Master Poster

Here is a tutorial on DLLs. It includes writing them, but the part on explicit linking is the one that shows how to load one. You can read more about LoadLibrary here.

abhipro commented: Helped a lot. Thanks +1
Tom Gunn 1,164 Practically a Master Poster

Is it possible to add the last post part from the forum list to the favorites list? And maybe also a link to mark all favorite forums as read? :)

Tom Gunn 1,164 Practically a Master Poster

i am very poor in programming coding ...

The only way to fix that is by writing code. It is best to start small and build on your achievements than to start with something too complex for your skills.

Tom Gunn 1,164 Practically a Master Poster

Look up the next_permutation() and prev_permutation() functions in the <algorithm> header. Literally, by the way. They are template functions, so you can open that header as a text document and read the implementation to figure out how it is done. :)

Tom Gunn 1,164 Practically a Master Poster

In your project properties there is a linker tab. You can specify libraries and directories there.

Tom Gunn 1,164 Practically a Master Poster

So something along the lines of this?

Close.

using namespace std;

The prevailing opinion is that a using directive should not be used at global scope. You can put this same line inside main() and have the same effect without making the std namespace visible everywhere else too. In a little program like this it is not a big deal, but name collisions become a problem very quickly as your programs grow.

cout << "error open the file" << endl;

While there is nothing wrong with this, it is not informative. Why did the file not open? I am not 100% sure that this is portable with fstreams, but I have always used perror() to get more details. You can find perror() in the <cstdio> header.

return 1;

Technically this is not portable because you do not know that an error code of 1 means the same thing on every system. For a generic error return it is more portable to return EXIT_FAILURE from the <cstdlib> header:

if (!ifile)
{
    perror("Error opening file");
    return EXIT_FAILURE;
}
while (! ifile.eof() )

This is not a good idea because eof() does not work in the same order that you expect. eof() only returns true after a failed read, which means that in some cases you will loop over the last line in the file twice. getline() returns a reference to the stream, and you can use that as a condition because reading to the …

Tom Gunn 1,164 Practically a Master Poster

Usually libraries will come with a .lib or .dll file that you can link with, and headers for compiling. But if you have all of the source, you might be able to build it all fresh too.

Tom Gunn 1,164 Practically a Master Poster

Close, but a temporary copy of the object is still an independent copy. C++ does not make reference copies of objects like Java or C#. To replace the object the iterator refers to, you need to assign to the dereferenced iterator. This will overwrite the object that it refers to:

bool updateListElement(Object* air)
{
    std::list <Object>::iterator iObject;
     for (iObject= list.begin(); iObject != list.end(); ++iObject)
     {
        Object temp = *iObject;
        if (temp.getCode() == air->getCode())
        {
            *iObject = *air;
            return true;
        }
     }
     return false;
}
Tom Gunn 1,164 Practically a Master Poster

Both and neither. Your question is much too vague to answer. Any objective comparison needs to be very specific about what is being tested and using equivalent code.

Tom Gunn 1,164 Practically a Master Poster

Just print the file line by line. Not all lines in C++ end with a semicolon, but they do end with a line break. ;)

Tom Gunn 1,164 Practically a Master Poster

When the value of a variable changes without any kind of modifying statement on it, you should look for memory corruption like buffer overflows and bogus pointers. I can help you look for it if you can pare your code down to a small but complete program that still has the problem. Looking for that kind of thing in a snippet is probably not going to be productive.

Tom Gunn 1,164 Practically a Master Poster

The easiest way to do this is to open the .cpp file and display it using cout. As a hint for a program displaying its own code, there is a preprocessor macro called __FILE__ that evaluates to a string with the name of the current file. This is the simplest type of quine that I have been able to figure out. ;)

The trick is to remember that it is not the code that is running, it is a compiled executable that was copied into memory. All of the files used to create that executable, and even the executable itself, are all just regular files that you can open and read.

Tom Gunn 1,164 Practically a Master Poster

the out put is 1, when i have the prototype of the function
4 if i dont have the prototype of the function .

If there is no prototype for a function at the time it is called, the compiler will assume that the function returns int.

if i write any functions in sizeof operator its not generating any errors

In the case of a function return value, sizeof will evaluate the type of the object that the function returns. You are not getting the size of the function itself. I am not even sure how that would work. ;)

ii) i have debugged the code using GDB its doesnt jump to the function calls when functions are included in the sizeof operators
not even bothered whether function names are correct.

Yes! This is a tricky point where you can write correct code that looks wrong. For example:

int* p = malloc(sizeof *p);

Oh noes! An uninitialized pointer is being dereferenced and that is undefined behavior! But the code is correct and nothing is wrong with it because sizeof does not evaluate the expression. It only evaluates the type of the result of the expression. So the pointer is not being dereferenced at all, just like your functions are not being called. A more obvious test follows:

#include <stdio.h>

int main()
{
    int value;

    printf("%d\n", value = 123);
    printf("%lu\n", (unsigned long)sizeof(value = 456));
    printf("%d\n", value);

    return 0;
}

123 will be printed because the …

Tom Gunn 1,164 Practically a Master Poster

So i thought create the tree in a binary tree it would be easier to handle.

I disagree. You can manually create the tree easily since it is small and the rules for red black insertion are simple. But if this is a school exercise, I can guarantee that adding the next three nodes will require rotations. So you will be writing a red black insertion function anyway. It is easier to create the tree using that algorithm from the start.

Tom Gunn 1,164 Practically a Master Poster

how can I restrict that this function has to be member of a specified class only?

You can remove the template and use a specific class if there is no need for generality:

real Integral(myclass& obj, real (myclass::*func)(real), real lower_bound, real upper_bound)
{
    //...
}

Are there any solution in which
you not must to type the same code twice,
and it can act on normal and member functions too?

Not without being convoluted. The usage of normal and method pointers are different, so at the point of the call you need at least a specialization. You can pass that in as some variation of the strategy pattern, but it would probably be simpler to have two interfaces and one implementation if your integral algorithm does not need to call the pointers internally.

This is wrong! How can i use "this"?

this is a pointer, but Integral() takes a reference to an object. You need to dereference this first:

return Integral(*this, &myclass::func1, a, b);
Tom Gunn 1,164 Practically a Master Poster

is sizeof an opearator(i actually studied it as a operator but then not so serious about the things)

Yes, it is an operator just like return , or = , or << . Sometimes it looks like a function because of parentheses around the operand, but that is just an appearance thing. Any expression can have redundant parentheses. :)

1.why is it called as an opeartor?

Because as an operator it is easier for the compiler to implement. Operators can be evaluated at compile time, and type information is available at compile time. sizeof is defined as evaluating to a compile time constant, so being an operator makes the most sense.

2.sizeof is compile time operator. what does that mean ?

It means that sizeof(expr) will probably be processed by the compiler and replaced with a constant value before generating object code. For example, if the size of an int is 4 on a hypothetical machine, the compiler might process printf("%lu\n", (unsigned long)sizeof(int)); and replace it with printf("%lu\n", (unsigned long)4UL); .

3.what about all other opearators arent they compile time?

If all parts of an expression are compile time constants, it can be evaluated at compile time, but might not be. That is up to the compiler. Otherwise it will be evaluated at run time because it relies on run time values and there is no other option.

when can i ignore the paranthesis around the argument.

When the operand is an object you can omit …

Tom Gunn 1,164 Practically a Master Poster

confused here on how the mapping is done between read ,write and scanf ,printf. because read/write takes file descriptors, buffers and size of data where as printf and scanf takes the variable lenght args: format strings and arguments

It is not a direct mapping. printf() for example does a lot of work to parse the format string and the variable arguments. It also handles output formatting because write() does not do any of that. The file descriptor is usually stored in the FILE object for stdout that printf() uses along with other information needed to make the system calls.

Gaiety commented: Thank a lot Tom U have been so helpfull +1
Tom Gunn 1,164 Practically a Master Poster

A red black tree is more than just a binary search tree with nodes marked red and black. The structure also has to be balanced according to the red black rules. Why not do a red black insert in the first place instead of trying to convert between a simple binary search tree and a balanced red black tree?

Tom Gunn 1,164 Practically a Master Poster

Why do you write:
template <typename ClassType>
why not:
template <class ClassType> ?

Personal preference. They both mean and do the same thing in this case. I use typename instead of class because it makes me look like a hip C++ guru who is down with the latest language standard. ;)

It is not possible to solve this with only one "function identifier" parameter passing to the Integrae function?

Maybe. It really depends on what myclass::classfunction() is supposed to do. If it modifies the state of an object and you want to keep that modification, you need some way of passing or returning the object that the method pointer is called on. Otherwise you can create a dummy object in the Integral() function, call the method pointer on it and throw it away. But then I would ask why you want to use a method pointer in the first place when it makes no difference. :D

Tom Gunn 1,164 Practically a Master Poster
lookin dat dar string
    izzit dat vowuel?
        yup, stop lookin'
        nope, keepa goin'

didja find it?
    yup, hola!
    nope, hola louda!
Tom Gunn 1,164 Practically a Master Poster

Thanks, but when I implemented your hash function it took nearly twice as long.

OK, by optimize you mean speed and not collisions. Your algorithm is about as fast as it gets without having excessive collisions or doing micro optimizations. Are you trying to increase the speed because you have proven it to be too slow with a profiler? If not, do not bother because programmers are very bad at guessing where performance bottlenecks are.

Tom Gunn 1,164 Practically a Master Poster

Numbers which start with a 0.

You should ask whether leading 0's should be taken into account, because if you write code that does so and it is not part of the problem, you will not get the question right. Leading 0's are usually only used as padding for display and sorting, not as significant value digits. If your algorithm assumes that padding is significant, it will always start at 0 instead of the first value with n significant digits, which is probably not what the interviewer wants. Solving the wrong problem is a great way to fail interviews.

Tom Gunn 1,164 Practically a Master Poster

Any shared resources should be protected somehow. If the singleton is a singleton across threads and not a singleton per thread then you do need to think about concurrency errors.

Tom Gunn 1,164 Practically a Master Poster
d=strupr(s1);

d is an array, but strupr() returns a pointer to char. That is a type mismatch on the one hand, and on the other you cannot assign to an array.

Tom Gunn 1,164 Practically a Master Poster

Yes it is. But it is also called C++Builder, not Turbo C++.

No, I was wrong. Turbo C++ 2006, also called Turbo C++ Explorer, is not available anymore. It looks like the only free option now is a trial version of C++ Builder.

William was advising against the use of Turbo C++, not C++ Builder and they are not the same thing.

I know what William was advising against, but for the last few years Turbo C++ had been resurrected as Turbo C++ Explorer, with the 2006 version of Borland's compiler. I saw it the same as condemning VS2008 based on the problems of VS6, so I was making sure that everyone knew a more recent version of Turbo C++ was available. But I was wrong and that version is not available anymore, so it is safe to assume any mention of Turbo C++ means the ancient versions.

I apologize for giving outdated information. It was accurate when I checked a few months ago, and I made an unwarranted assumption that it was still accurate.

Tom Gunn 1,164 Practically a Master Poster

If i just have 3 data in the tree, eg: 1, 2 and 3, and i remove 1 in thee, should 3 become the new root in this tree?

If 1 is the root, then either 2 or 3 could be the new root. You can pick whether the inorder predecessor or successor becomes the new root. But it is not as easy as just making the root's immediate left or right child the new root because you still have to maintain the binary search invariant that an inorder traversal produces a sequence that is sorted in ascending order.

Tom Gunn 1,164 Practically a Master Poster

input == depth will happen for every node at that depth. You only want to print the total after the function returns instead of inside the recursive function. A reference parameter would be better suited to that:

#include <iostream>

struct treeNode
{
    int data;
    treeNode* left;
    treeNode* right;

    treeNode(int data, treeNode* left, treeNode* right)
    {
        this->data = data;
        this->left = left;
        this->right = right;
    }
};

void sumLevel(treeNode *&ptr, int input, int depth, int& depthTotal)
{
    if(input == depth)
    {
        depthTotal = depthTotal + ptr->data;
        return;
    }

    if(ptr->left != NULL)
    {
        sumLevel(ptr->left, input, depth - 1, depthTotal);
    }

    if(ptr->right != NULL)
    {
        sumLevel(ptr->right, input, depth - 1, depthTotal);
    }
}

int main()
{
    treeNode* root = 
        new treeNode(1,
            new treeNode(2,
                new treeNode(4, 0, 0),
                new treeNode(5, 0, 0)),
            new treeNode(3,
                new treeNode(6, 0, 0),
                new treeNode(7, 0, 0)));
    int sum = 0;

    sumLevel(root, -3, -1, sum);
    std::cout << sum << '\n';
}
simonsayz27 commented: A great help! +0
Tom Gunn 1,164 Practically a Master Poster

SAX was designed for hashing strings and is supposed to be really good for it:

unsigned hash(string const& key, unsigned tableSize)
{
    unsigned hashVal = 0;

    for (int x = 0; x < key.length(); ++x)
    {
        hashVal ^= (hashVal << 5) +
                   (hashVal >> 2) +
                   key[x];
    }

    return hashVal % tableSize;
}

Your algorithm is a common variation of a good hash that uses 33 instead of 37. It should work well in the general case.

Tom Gunn 1,164 Practically a Master Poster

When i remove the root of the binary tree and I view the binary tree in In-Order Traversal, my program will stop running.

Then you are not resetting the links the way they should be. Removing the root means replacing the root with either the inorder predecessor or successor. Something like this:

Original:
    D
 B     F
A C   E G

Delete the root:
    *
 B     F
A C   E G

Make the inorder predecessor the root:
    C
 B     F
A *   E G

Delete the inorder predecessor:
    C
 B     F
A     E G

That behavior should fall out of your deletion algorithm because it is the same as the two child case for any node. But you also need to reset the root pointer. In the example above, if root still points to D after the algorithm finishes, the tree will be broken. So at the end, the address of C should be assigned to root to finish things up, but only if it was D that was deleted. That is an easy test because parent will be NULL if the root has a matching value.

cjjack88 commented: nice explaination +1
Tom Gunn 1,164 Practically a Master Poster

As I said, you can use any debugger you want. But if there is no debug information, you will not get source code matching, just a disassembly. The debug information comes from the compiler, which is why matching the compiler and debugger makes life easier.

Your options have not changed:

  • Port the code to another compiler and use the paired debugger.
  • Use any debugger you want and work with the assembly listing.
  • Use the debugger that came with Aztec C in an emulator, if there is one.
Tom Gunn 1,164 Practically a Master Poster

Pointers to functions and pointers to methods are not the same thing. A pointer to a method is really an offset into the class, not a real pointer with an address value. You need to make two overloads of the Integral() function. One that takes a function pointer and one that takes a method pointer:

#include <iostream>

typedef double real;

real Integral(real (*func)(real))
{
    return func(0);
}

template <typename ClassType>
real Integral(ClassType& obj, real (ClassType::*func)(real))
{
    return (obj.*func)(0);
}

class myclass{
public:  
    real classfunction(real);
};

real myclass::classfunction(real x)
{
    return 3.14;
};

real myfunc(real x)
{
    return 1.23;
}

int main()
{
    myclass probe;

    std::cout << Integral(myfunc) << '\n'
              << Integral(probe, &myclass::classfunction) << '\n';
}

An extra complexity with pointers to class members is that the pointer is defined on the class, but to use the pointer you need an object of that class to access the member. That is why the Integral() overload for the member pointer also has an argument for an object of the class type.

Tom Gunn 1,164 Practically a Master Poster

Is there any way to make VS2005 use the Aztec C compiler commands (from Aztec BIN folder)?

No, but if the code does not rely on extensions to the language/library by Aztec C, you can probably port the code to VS2005 without much trouble. I am not sure if the code you want to debug is pre-standard or not, but VC does allow K&R style code still, so that should not be a huge problem.

If not VS2005, is there some way I can debug the program?

Most debuggers will not care what compiler compiled the executable, but you will not get pretty source level information. That will make debugging harder.

Tom Gunn 1,164 Practically a Master Poster

i would like to know the way we can make user enter a number in a menu reply perhaps so that he doesnt have to press the enter key

For this question we need to know what compiler and OS you use because there are no portable answers that will work everywhere. The answer needs to be tailored to your setup.

Just be wary that the getch() function and the associated conio.h header file are not portable.

This caveat applies to every solution because the problem itself is not portable. There is no standard way in C to read input without the possibility of buffering at a higher level. It is a system dependency.

Tom Gunn 1,164 Practically a Master Poster

I made one code but doesn't work!!!

If you do not post the code and ask a specific question about it, everyone is going to assume you want someone else to do your homework for you.