~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Going by the normal C/C++ tip:
do int i = 0; instead of:

int i;
i = 0;

So when you know the value for a variable at the time of it's creation it's better to initialize it to save a li'l time, rather than letting SOME value being set in initialization and then assigning it.

AFAIK, this is not the case. When a variable is declared, a block of memory is reserved for it and thats it. No default initialization is done. Its because of this we get junk values when we try using uninitialized variables. This value is interpreted based on the contents of those memory location and the type of variable under consideration.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You just need to add a newline the moment you have displayed four randoms.

for(int i = 0; i < 100; ++i)
{
     if(i % 4 == 0)
         putchar('\n');
     cout << randomNumber;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

..because you failed to provide an implementation for the non-virtual function.

class abc
{
    public: virtual ~abc() {} 
    static void operator delete(void*) { /*do something*/}
};
int main(int argc, char *argv[])
{
    abc _a; return 0;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> But where did it get the arrows from? Was the iterator getting
> incremented beyond the number of players?
Your iterator was in an invalid state and you try to access it. Simple.

> Just don't become a teacher OK?
You are being unnecessarily harsh here; she was trying to help you out. The negative reputation was so uncalled for. Such kind of attitude would make a contributing poster think twice before helping you out.

Hope you understand.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

No need of another buffer, a simple swap should do the trick.

int i, j;
    char ch;
    for(i = 0, j = nblocks - 1; i <= j; ++i, --j)
    {
        ch = iobuf[i];
        iobuf[i] = iobuf[j];
        iobuf[j] = ch;
    }
    fwrite(iobuf, 1, nblocks, out);
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yet another classic example of why globals should be best avoided. The culprit here is the iterator variable 'iter' which you chose to share among all your function calls resulting in side effects. The fact that the function mainTurn() along with all its sub functions like 'wordAffairs()' share the same variable causes the 'funny character printing syndrome'.

Create a local variable for each function call when global state is not explicitly required and you should be good to go.

Add a line list<humanPlayer>::iterator iter; at the start of mainTurn() function. Plus the logic for rotating turn looks fishy to me.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Plus you can safely do away with the language='javascript' attribute since Javascript is the default scripting engine for all browsers. Use this tag only when you are using two or more scripting languages. Eg. VBScript etc.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    size_t filesize;
    size_t nblocks = 1;
    FILE *in, *out;

    /* check no. of arguments */
    if (argc != 3) {
        fprintf(stderr, "%s: incorrect arguments\n",
            argv[0]);
        return 1;
    }

    /* open the input file */
    if ((in = fopen(argv[1], "rb")) == NULL) {
        fprintf(stderr, "%s: can't open %s\n",
                argv[0], argv[1]);
        exit(1);
    }

    /* open the target file */
    if ((out = fopen(argv[2], "wb")) == NULL) {
        fprintf(stderr, "%s: can't open %s\n",
                argv[0], argv[2]);
        exit(1);
    }

    /* move pointer to end of input file */
    if(fseek(in, 0L, SEEK_END) != 0) {
        perror("fseek(in, 0L, SEEK_END");
        exit(1);
    }

    /* get current file position in input file*/
    nblocks = ftell(in);
    rewind(in);

    char *ptr = 0;
    char *iobuf = (char*)malloc(sizeof(char) * nblocks);

    /* read input file into buffer */

    if(fread(iobuf, 1, nblocks, in) != nblocks){
        fprintf(stderr, "fread failed\n");
        exit(1);
    }


    fclose(in);
    fwrite(iobuf, 1, nblocks, out);
    /*
    for(ptr = iobuf; ptr <= iobuf; ptr++)
    {
        fputc(*ptr, out);
    }
    */
    free(iobuf);
    fclose(out);

    exit(0);
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You are using the fread function incorrectly by swapping the position of the second and third parameter. The second parameter is not the size of the entire file, but the size of each chunk.

Try changing to fread(iobuf, nblocks, filesize, in) and it should work out to be fine.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I guess I got confused between array initializers and memset. Hmm..but I do vaguely recollect someone mentioning something similar a long time back on the newsgroups.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

But int arr[BUFSIZ] = {0}; internally uses memset to actually perform its task.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Just to let you know, there are two more methods of doing the same thing: (but still not recommended)

int arr[20];

//first, 
for(int i = 0; i < 20; ++i)
   arr[i] = 0;

//second, better than first.
memset(arr, 0, 20);
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Asking the question here would be more productive.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You are creating an array of strings in which each 'cell' would contain a string and initializing those strings to contain 20 characters. (approx). You either need to do

string ar[21] = " ";
//OR
string ar = "                    ";

And btw, you loop is off by one. You need to loop from 0 to 20 and not 0 to 19.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> What vector? I don't see any vectors.
I guess he meant the list.

list<humanPlayer>::iterator iter;
for(iter = jailHouse.begin(); iter != jailHouse.end(); ++iter)
{
    //now dereference the iterator and you get access to your instance
   cout << iter->getPlayerName();
   cout << (*iter).getPlayerTurnNum();
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Try out the approach provided by thekashyap in post #11.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Probably do what ~s.o.s~ said, he knows better than me. ;-)
You are too kind my friend. ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

In such a scenario, its always recommended that the function 'getName()' return an newly created array instead of incurring the pain of creating an array variable and passing it around.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

No need for a pointer. Just keep on passing the array name wherever you like, a pointer to the array would be automatically passed since the array name is the pointer to its first element.

void createArray()
{
    int* myArr = new int[10];
    useArray(myArr, 10);
}

void useArray(int arr[], int sz)
{
    for(int i = 0; i < sz; ++i)
        arr[i] = 0;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Something like this?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I guess what he meant was:

> and to provide c>you et al an opportunity to
and to provide you, with other things, an opportunity to

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

But the fact remains that you _do_ have to study them by hook or by crook. Otherwise how do you expect to clear the test?

Here is a site which would help you in learning them with those pretty visualizations.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> i do not know these algorithms
You would have to learn them to solve the problem at hand. Try the wikipedia. It should help you in getting started at least.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hehe, what an apt name given to that rogue of a smiley. ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

= is the assignment operator, and is basically used for assigning values to variables. What you need is the comparison operator == to compare values.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> day=(x.day).operator- (day); There is a reason we do operator overloading. Don't you think the code above looks a bit illogical.

Read up on some good operator overloading tutorials to actually understand what it is used for. And BTW, operator overloading is used as: obj1 = obj2 - obj3; where all objects are instances of the same class and you have specifically overloaded the minus(-) operator.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Any kind of credit is appreciated. ;-)

Good luck.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Try using this:

<html>
<head>
<script>
    var ENTER_KEY = 13;

    function myKeyPressed(e)
    {
        if(!e)
            var e = window.event;
        if(e.keyCode)
            code = e.keyCode;
        else if(e.which)
            code = e.which;

        if(code == ENTER_KEY)
        {
            alert('You pressed the ENTER key');
            return true;
            //call the function which performs calculation
        }
        else
        {
            alert('Press the correct key');
            return false;
        }
    }
</script>
</head>
<body>
<form>
    <label>Box</label><input type="text" name="txt" id="txt" onkeypress="javascript:return myKeyPressed(event)" />
</form>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

But the question here is which method. You can always write a servlet which would handle the client request when the 'submit' button is pressed.

After that, its a simple thing of pulling out the text box values using request.getParameter("textBoxName") .

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It doesn't work is pretty vague description. You need to tell me what error or output it gives. BTW, I have tested it on Firefox so you might want to try that out. The event model of IE is pretty broken up.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Frames are evil. Whatever you are planning to do can be very well achieved without the help of frames.

As for the return key detection, here is a small example:

<html>
<head>
<script>
    var ENTER_KEY = 13;

    function myKeyPressed(e)
    {
        if(!e)
            var e = window.event;
        if(e.keycode)
            code = e.keycode;
        else if(e.which)
            code = e.which;

        if(code == ENTER_KEY)
        {
            alert('You pressed the ENTER key');
            //call the function which performs calculation
        }
        else
            alert('Press the correct key');
    }
</script>
</head>
<body>
<form>
    <label>Box</label><input type="text" name="txt" id="txt" onkeypress="javascript:myKeyPressed(event)" />
</form>
</body>
</html>
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You would need a third party API to achieve since standard C/C++ doesn't cater to GUI requirements of the programmer like modern languages.

wxWidgets and GTK+ are a few famous names you get to hear.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Maybe you need to post a bit more code, or atleast have stab at it. In case you are finding it difficult, I would recommend reading some good books and tutorials.

If you have something concrete, do come back and we would definitely help you out.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

cout << ps->first_name << ps->last_name << ps->id_no << ps->age << endl;

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A smart combination of Graphics card and RAM should set things alright for a gamer. Also it depends on the game you are about to play. Games like `Stalker: Shadows of Chernobyl' though recent require a minimal configuration. On the other hand, `Elder Scrolls' requires you to have a solid configuration for a uninterrupted game play.

Considering that you have 1GiB of RAM, you need to get a decent graphic card if you already haven't got one.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> So, multitasking is a more simple concept of multithreading?
Mutitasking is what your operating systems are packed with. You have the ability to execute more than one tasks / processes. You can read an ebook using Acrobat reader at the same time download something. You are given the feeling that its all happening at the same time even though its not. The OS allocates time slices or frames to each of these processes and these slices are so small that you get the feeling of multiple tasks being executed simultaneously. It is made possible through 'task switching'.

Multi-threading is tightly bound to the concept of using more than one threads to execute the same task. Thus you can have more than one tasks running and for each task there would be multiple threads. Threads are handled almost in the same way as tasks though there are subtle differences. Thus in lay man's terms:

Multi-tasking - more than one application running
Multi-threading - more than one threads running per application

John A commented: Right... I knew that. I just forgot about that little detail [noparse]:P[/noparse] +13
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> double duration = Math.ceil(-Math.log10(1 - a * r / p) / Math.log10(1 + r))

Yes, provided you write your own function "log10" based on what I had posted before.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Your formula appears to be incorrect. Your log function is not taking any arguments, when it should be talking one. See the one I posted in my previous post.

The log function in the Math class gives us log to the base e, that is natural log. For normal calculations, we use log to the base 10. Hence we have to do some adjustments specified by me in my previous post.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Replace all integers with float and change all "%d" to "%f", even in the scanf statement. Also post the results you get when you use ints and when you use floats.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

How about something like: double duration = Math.ceil(-Math.log(1 - a * r / p) / Math.log(1 + r)) Though I would like to point out here that the log use here is to the natural base (e) so you might want to convert it so that it is to base 10 using the formula: log A(base 10) = log A (base [I]e) / [/I]log 10 (base [I]e[/I])

peter_budo commented: Great examples +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

In that case, linking to google with a proper search term would have been more like it since its likely that with a proper search term, the results would have been more rewarding. Linking to just Google, makes no sense.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> he's not talking about threading im sure.
For a small scale project, yes, but for real games, multi threading is what he is looking for. Games almost always make use of multi threading.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Reading this thread thoroughly might give you some link...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You forgot to do:

if(rs.next())
{
//your code which uses rs
}

You got to realize that unless you do a next on the recordset, it isn't actually pointing to anything, this is because the implicit cursor in any kind of database always points to the nothingness.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

When you perform any kind of transformations on the scene or on any object, its transformation matrix (the way with which it is displayed) is modified. When any transformations are performed, they are performed on the current matrix which is then modified depending on the operation to be performed.

Since for that particular code snippet, a clean matrix was required, it was necessary to reset the transformation to identity matrix. Hope it made sense, haven't been in touch with graphics for a long time.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

OpenGL is a graphics API, just like DirectX with the good thing being supported on all platforms. Not to mention it has a lot of bindings (like Java and OpenGL binding called JOGL). But if you are planning to go into the gaming industry, DirectX is the one you should be looking at considering that all the games are aimed at Windows platform. Search up on OpenGL in Google and you would get to read a lot of interesting articles.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

But of course your mother must have made a logical decision after doing a lot of research.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You should probably post a working code here along with the explanation of what it does. Making us guess what your code does is not a good idea. Post the complete code (along with main) along with the sample input data supplied and the expected output.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

..or just take the numbers in a single go in a string variable and do something like: string result = string(10, '0').substr(10 - number.size()) + number;

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Yet another way:

string city = "Memphis";
string state = "Tennessee";
string result = city + string(16, ' ').substr(city.size()) + state;