deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Create a TcpClient and connect to the POP3 server, open a NetworkStream that uses the client and download all the data available. You can then parse this using the POP3 specification.

That's a gross oversimplification. ;) Doing it right is a non-trivial task, so I'd recommend utilizing a library like OpenPOP that already has all of the grunt work done.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Chr(e.KeyCode) always returns capital letters

Yes, because the KeyCode property doesn't include shift state. There's also a Shift property for KeyEventArgs that tells you whether the shift key was pressed (and Alt, and Ctrl). You might consider whether the KeyData or KeyValue properties suit your needs better.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

MASM is just an assembler, IIRC. Are you also running a linker after assembling source into object code?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yeah.. the server is going to get overwhelmed. Why is anyone surprised?

Given that it's easy to imagine such a situation, I'm surprised that they didn't make sure the server (or server farm) was sufficiently beefy given the exorbitant cost of a single website. What we're looking at is just plain ol' incompetence.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Lowest bidder.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

mingw32... but i think that it's the GNU too

MinGW's implementation may not use the highest resolution implementation. You might try Boost.Chrono. IIRC, it uses QueryPerformanceCounter under the hood, which is the best you can get in terms of granularity. However, note that on Windows you can't reliably get a higher resolution than 1μs in certain increasingly common circumstances (eg. multicore processors). But it should be sufficient for your current needs.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What compiler are you using?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

*nix is a colloquialism to describe POSIX-based operating systems such as Unix or Linux.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

iostream declares them to be publicly visible (within the std namespace). If you open up iostream you'll see how they're declared, but all you may see are extern declarations.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Seeing the actual error would help, but I suspect it's coming from line 40. The ostream class doesn't expose a public default constructor. Really your only option is to pass in a pointer to a streambuf object that handles all of the nitty gritty details of reading from the stream.

Note that streambuf also has a protected constructor, which means you need to derive your own custom stream buffer class to pass into ostream. Alternatively you can reuse an existing streambuf. For example, if you want your ostream to essentually do the same thing as cout, you can do this:

#include <iostream>
#include <ostream>

using namespace std;

int main()
{
    ostream obj(cout.rdbuf());

    obj << "Hello, world!\n";
}

It's largely pointless though, since cout is already available.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If comboBox2 is tied to comboBox1 without binding, you'd need to programmatically select the new value in comboBox1 when comboBox2 changes.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You can set SelectedIndex, if that's what you're asking.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Here's an example that may help. Note that it's not a complete solution to your problem, just a similar example:

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int draw_card()
{
    return 1 + rand() % 100; // [1,100]
}

int main(void)
{
    int wins = 0, losses = 0;

    srand((unsigned)time(NULL));

    // Game loop: plays infinite rounds of HiLo
    while (1) {
        int card = draw_card();
        int guess;

        fputs("High(1) or Low(2)? ", stdout);
        fflush(stdout);

        // Get a sanitized guess
        while (scanf(" %d", &guess) != 1 || (guess != 1 && guess != 2)) {
            puts("Invalid option");
        }

        // Clear extraneous characters from the stream
        while (getchar() != '\n');

        // Check the guess, notify, and update stats
        if (guess == 1) {
            if (card >= draw_card()) {
                puts("You win!");
                ++wins;
            }
            else {
                puts("You lose");
                ++losses;
            }
        }
        else {
            if (card < draw_card()) {
                puts("You win!");
                ++wins;
            }
            else {
                puts("You lose");
                ++losses;
            }
        }

        // Give the user the option to quit
        fputs("Play another round? (y/n): ", stdout);
        fflush(stdout);

        if (tolower(getchar()) != 'y') {
            break;
        }
    }

    printf("Final Score: wins(%d) losses(%d)\n", wins, losses);

    return 0;
}
Pashan commented: you are awesome! +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

In India, schools have unfortunately standardized around Turbo C/C++.

It's an unfortunate reality that we have to deal with constantly. The result is that C++ programmers graduating from Indian schools are woefully under-skilled due to reliance on outdated tools. C++ has evolved significantly since Turbo C++.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Break down the requirements into manageable chunks. I'd do it like this:

  1. Play a single round of HiLo with numbers from 1 to 100.
  2. Modify the program to play infinite rounds.
  3. Modify the program to keep score or wins and losses.
  4. Modify the program to let the user stop after each round.
  5. Modify the program to use "cards" instead of a simple number range. Reshuffle the deck on each round.
  6. Modify the program to use a full deck before reshuffling.
  7. Profit!

This incremental approach keeps things simple as you only have to worry about a subset of the requirements at any given time. Further, when adding new requirements, you already have a fully working program to build upon.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

while you sit idely in your parents basement on the computer all day judging peoples lives keep in mind the rest of us have real jobs and real concerns to worry about and we work long hours and barely make ends meet so don't ever assume you know what were going through you dont know what we've been through plain and simple

In your rage post, I think you may have missed the glaring contradictions. You tell us not to assume stuff about you while you do exactly the same thing in the same sentence. Somehow that doesn't encourage me to respect your opinion.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Flute.

nitin1 commented: you have told me long time back :D +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

when is a destructor of a class called?

When the object goes out of scope or a pointer to the object is deleted.

I'm assuming that when I pop a vector, that will make the pointer no longer valid, is this where the destructor gets called?

Yes, assuming that the object stored in the vector is an object and not a pointer to an object that was dynamically allocated. If you use new or new[], the onus is on you to call delete at the right time.

It's hard to say why your code is locking up without seeing a relevant skeleton.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

At that granularity, everything is efficient. However, tricks for swapping without a temporary variable have a higher chance of not being as efficient due to potentially confusing the compiler's optimizer.

The lesson to be learned is that it's not worth trying to optimize a few bytes from a single scalar object. You'll get far better returns on the investment of reducing memory usage from large aggregates or optimizing algorithms with a larger impact on performance.

Also, it's rare when you can achieve both space and speed savings; most of the time you can only get one at the cost of the other.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The code will compile, but the subscript operator for std::vector does not throw an exception. To get an out of range exception you must use the at member function.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'd use public transportation if it were convenient and cheap for my area...but it's not.

I'd ride my bicycle to work in a heartbeat...if it weren't a death trap.

So I drive my car.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'd use a tuple for heterogenous and/or fixed aggregates. Otherwise I'd use a list. Of course, there are always exceptions, but that's a generally universal guideline.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

but dont come on a site trying to make people feel bad about the issues they have had with breast feeding.

As opposed to coming onto a techical site asking an obviously impossible to answer question about politics? I'm almost tempted to view this thread as a trolling attempt.

Dearden commented: not helpful +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I understand that's not your point, but please understand that your question is impossible to answer without inside knowledge. We can only speculate.

What I can do is observe that the question presumes financial support for infant formula is truly needed. That may very well be the case, but it might also be the case that a doctor didn't try to ascertain the underlying issue and simply prescribed formula as a band-aid. In that case, the proper solution is not to assist in purchasing formula, but to assist in medical expenses for fixing the real problem.

My purpose in pointing that out is to reach a logical rationale about why related programs could have been shut down.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

copyGamma(inStock, 0, gamma);

You're passing 0 into numRows and never change that before the loop. Is 0 less than 0? Because that's the first condition for entering the outer loop, which means it will not be executed because the condition fails.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The way you've indented your code suggests the error. If nextRow++ needs to be inside the inner loop, the loop body must be surrounded with braces:

for (col = 0; col < NUM_FOUR; col++)
{
    matrix[(nextRow)][col] = matrix[(row)][col] * 3;
    nextRow++;
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

In that case I'd question why the baby won't latch. Something is wrong if the natural process of nurturing isn't working. Then again, I'm a problem solver and not a doctor. In my experience, doctors have a tendency to treat symptoms without digging deeper to correct the root cause.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm curious, what's wrong with breast milk? Completely free, and arguably healthier in the long term.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What about pictures in posts?

That's fully supported. In the editor tool bar you can add files with the Files button. Image files that are uploaded can be embedded in a post. However, please note that if you put that picture on every post as a way to get around the limitations of the signature feature, it may be flagged as a fake signature and removed as per our rules.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

D'you think you'll be releasing images soon?

It's working by design. We have no plans currently to support images in signatures. Might I suggest using your picture as your avatar? That would produce more or less the same effect.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Signatures are text only. Feel free to use the link though.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So I would assume that by looking at the stream data (in its encoded form) there may or may not be a way of telling what kind of filter to apply to it in order to decode it.

I don't doubt it, but that may be excessively difficult. You're in luck though, as many file formats will have an identifying prefix in the byte stream that you can use. For example:

Zip:     50 4B
Rar:     52 61 72 21
Tar-LZW: 1F 9D
GZip:    1F 8B
DEFLATE: 78 9C
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What do you mean by how to identify it? When looking at an encoding algorithm, or the resulting encoded bytes?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is it because you're guys?!

I'm not sure how that would make a difference.

I'm really lucky if I get a little elliptical workout in every so often, and I'm content with that!

If it's important enough to you, you can make time for it. My workouts are quick, but effective. Since I live 10 minutes from work, the time I'd spend commuting can be factored into the workour also. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Then I'm not sure. You're definitely missing a definition for the sum constructor, but that shouldn't cause a linker error with add.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

How are you building the files together into an executable? The code looks fine, but the errors suggests that main.cpp and definition.cpp aren't linked together.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Do you have any extensions or non-standard toolbars enabled on your browser? I've been test with a relatively clean install of Opera (as it's not my main broser), and usually issues like this are caused by some conflicting extension or running program.

That said, while Dani may not run Daniweb through the gamut of browsers, I do. And I've make sure that all of the big name desktop browsers don't have obvious reproducible issues. ;) However, there are so many variables involved it's difficult to test exhaustively.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm unable to reproduce the vaguely stated problem on Opera. Can you provide precise reproduction steps?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It'll compile if you're lucky (probably not though), and you won't get past linking because the underlying library is missing. To make it more obvious what will happen, consider downloading windows.h onto a Linux machine and imagine how far you'd get.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Like when u say "conio.h is not supported", so compiler doesn't support ? How can it be ?

The compiler must implement certain libraries as specified in the ISO standard, these include stdio, stdlib, string, and ctype. Any other libraries are not required, and the compiler vendor can choose not to implement them. The conio library is one such non-standard library, so not all compilers will implement it.

Headers are merely the "public interface" for a library.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

1 - why they want const be uppercase?

It's a naming convention that makes such constants stand out.

2 - why some people adive me use '{' after function\class name and not in next line?

It's just a programming style and makes no difference as long as you're consistent with it. Pick the one you like if you aren't already required to match company or project style guidelines.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

why the 'PRO's' want avoid the "\n"?

It's the opposite. You should avoid endl unless you know that the stream needs to be flushed afterward. Otherwise you should prefer '\n'. endl is implemented like this:

inline ostream& endl(ostream& out)
{
    out.put(out.widen('\n'));
    out.flush();
    return out;
}

There's always an implicit flush involved even if it's not needed.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Please ask a specific question. Simply posting your homework requirements suggests you want someone to do the work for you.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'll second Pelles C as a pure C compiler. That said, I don't currently use it because I switch between C and C++ a lot, and a C++ compiler (pretty much all of them are bundled with a C compiler) works better for my needs.

If you ever plan to use C++ as well, something like Visual Studio or Code::Blocks/CodeLite may be better. That way you can be used to the IDE's interface regardless of whether writing code in C or C++.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Hmmm, i never seemed to like any form of curling weights... they don't anything.

My biceps don't grow well just from compound movements, so I use curls to get better results.

But hey, the huge trick into getting in better shape is your diet and rest (sleep)... that covers 90% of the job ;)

Nutrition is a whole other can of worms. Don't get me started, or I may start talking about biochemistry. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Start from the simplest and work your way up: RLE, sliding window, LZW, and Huffman are the simpler algorithms. They're relatively easy to implement and reason about.

Production level algorithms tend to be either proprietary or variations/combinations of the simpler ones. Also keep in mind that different types of data compress differently and different algorithms will be optimal. For example, RLE variants are simple, but a solid winner in compression quality when you have text or binary that contains long spans of repeated values.

I'd probably browse Amazon for algorithm books and books specializing on compression algorithms and search Google for specific algorithms as a starting point. Wikipedia will give you a list of algorithms to do further reserach on.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So... what are your favorite workouts?

That's a slippery slope if you ask the right person. My favorite workout is a 4 day upper/lower body split:

Monday: Lower
Tuesday: Upper
Wednesday: Rest
Thursday: Upper
Friday: Lower
Weekend: Rest

The individual exercises vary, but my days are broken down into at least one movement on each plane as the base and additional supplementary exercises as I feel the need or desire:

Upper
  • Vertical pull (eg. Pullup)
  • Horizontal pull (eg. Row)
  • Vertical push (eg. Shoulder press)
  • Horizontal push (eg. Bench press)
Additional Upper
  • Face pulls
  • Biceps curls
  • Triceps presses
  • Pullovers
Lower
  • Push (eg. Squat or leg press)
  • Pull (eg. Deadlift, rack pull, etc...)
  • Calf raises (both seated and standing)
Additional Lower
  • Glute ham raises
  • Leg curls
  • Leg extensions
  • Toe lifts (not sure of the actual name, works the anterior tibialis)

Rep ranges vary depending on the exercise and current progression on weight. I pick a weight that gets me 5 reps where I start to struggle on the last rep, and increase reps until I can do about 10 without struggling, then reset with a higher weight.

With properly tuned reps, my sets naturally fall into the 3-5 range, so I don't usually bother counting them.

I don't do any form of cardio at the gym that doesn't come from lifting weights. However, I do play tennis, which is excellent cardio. :)

I think I remembered everything. Just doing the base …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The solution is the same: you need to save that information somewhere on every read or write. If you don't want to use a separate variable or wrap everything up in a class, then look up the xalloc/iword/pword member functions provided by ios_base.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

To write the file you'll loop through the items and save them to a text file (or a binary file if you so choose). There's a conversion involved to produce the file format you want.

To read the file you'll parse it, convert each record back to something that can be applied to a ListView item, apply it, and repeat for each record until the file is exhausted.

I get the impression that you think there will be a one line solution that magically converts a file to a ListView, which itself would require a bit of scaffolding that you'd have to write as well, if you want it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You can use whatever format you want.