deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Daniweb is not a homework for free service. Please show some proof of effort if you want help.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It sounds more like the issue is with creating a Windows Service. It's pretty straightforward as far as setting things up, though there are a huge number of variations depending on what you want to do and how you want to do it.

The MSDN tutorial is a good start.

The problem here is that you're asking for things that involve too much code to comfortably put in a post.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I have implemented OpenPOP methodology however it is developed in windows forms and I thought of some windows service to achieve this.

OpenPOP doesn't depend on Windows Forms, last I recall. There may be a Windows Forms test or utility, or something, but you should be able to ignroe it. You can use it in a class library or a Windows Service with no issues at all. Of this I'm sure, because I've done it before.

I used OpenPOP in a service before I moved to my own POP3 management library. And the only reason I moved to my own was to facilitate easier support of IMAP, OWA, and MAPI.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I mean "OOP" is vague.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i think it's basics of OOPL too

And therein lies the problem. There's not a single "official" definition of what features a language must have to call it object oriented.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

fun returns a reference to a static object, which you then set to 30. Subsequent calls to fun will return the same object, and you'll get the same value that you set.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

How soon sill they get around teaching with 2013 compilers that have dropped gets()??

Probably never. Why update your curriculum when you can install Virtual Box and simulate DOS to support an ancient compiler that conforms to the 30 year old curriculum? :rolleyes:

rubberman commented: Indeed! It is time to kill that dinosaur! +12
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I don't recall of the top of my head what the polling interval is for sending those emails. Now that we know you're watching this thread, give it 24 hours and let us know if you still don't get an email.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is the thread in your watched articles list?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Hop into your edit profile page and make sure that "automatically watch articles I post in" is checked. If it is, look for that thread in your watched articles page. I'd wager that you're simply not watching the article, so you won't get new post notifications.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Imperative, procedural, declarative, functional, object-oriented...there are many programming paradigms. C++ is largely imperative (inherited from C), supports OOP, and has been introducing functional aspects lately.

Try looking at Wikipedia for "programming paradigm".

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Which version of the Windows Phone OS?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Hopefully I shouldn't need to explain what gets is or why it's easily one of the worst possible standard functions you could call in your code. In my personal opinion, the title for "holy shit, never use this function" is a tie between gets and system. I'll discuss the problem with system in another article.

The good news is that gets is no longer a problem, provided you use the latest C11 standard. In the 1999 revision of the C language, gets was declared to be deprecated. This means that it was still supported, compilers still had to implement it correctly, but the even as soon as the next minor revision of the standard the function could be removed entirely. And hey, that's exactly what happened. The 2011 revision of C eliminated gets; it's no longer required to be supported, and any use of it makes your code non-portable. Rejoice!

Wait, why does this qualify as a tribal knowledge article? A quick Google search will tell you all you need to know. And while using Google to do research itself may qualify as tribal knowledge (*heavy sarcasm*), I'd hope it wouldn't be necessary to explain to most of you. ;)

No, this article will focus on what to do now that you no longer have guaranteed access to gets. The answer isn't quite as simple as "use fgets" because fgets has quirks too. Rather, let's look at a couple of hand rolled solutions that provide close to the same interface …

mike_2000_17 commented: Another insightful article! Thanks! +14
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What exactly is meant by embedded C programs? I'd assume that you'll be linking with built C object code, but that may not be a safe assumption here.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

How would I detect the use of Shift key?

Please read my post again. Not only did I describe exactly what you're asking, I linked to documentation on the KeyEventArgs class so that you can get full details.

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

For simple 1D barcodes like 3 of 9 or 128, you shouldn't need a barcode generator, just a font. The encoding of the value itself is straightforward with start-stop characters and in the case of code 128, a simple check digit calculation before the stop character. From there it's just a matter of printing text rather than generating an image.

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

Why would anyone put there self through this language

Because sometimes it's necessary when you want bare metal control, architecture-specific optimizations, or absolute performance. From my own experience, hardware drivers and the deepest bowels of compiler/library implementations tend to use at least a little bit of inline or straight assembly.

Sometimes you have no choice, as rubberman alluded to with boot loaders.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Just because something was called a certain way in the past or "has always been done that way" doesn't mean we should not question it and not try and find better ways of doing something

Did I mention the tagging system? ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

it is binary encoding method

Obviously. I meant what the binary represents when presented as character glyphs.

The first is that we do not know how many bits represent a character

That falls under the text encoding. ASCII is a 7 bit encoding and is stored in 8 bits. UTF-8 can be between 1 and 4 bytes. UTF-16 is 2 bytes, etc... But once you know what the encoding is, you can figure out how many bytes represent a single character the same way everyone else does: the rules of the encoding.

The second we do not know the type of binary encryption used to encrypt the code above.

You neglected to mention that we're looking at encrypted text and not plain text. That adds a whole other dimension to the problem. Now it's an cryptography theory problem, and for that I'll direct you to your nearest book store because that's a rather broad and intense field of study.

if you read carefully , when I post my question I wrote : "here is an example of random binary code"

I always read carefully, and I didn't miss that part of your post. If you read carefully, did you mention that the binary is encrypted? That drastically changes the nature of your question.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Can you provide a realistic example of the behavior you want to achieve?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Prevents me from having to scroll up to figure out which block this bracket belongs to.

Unless you're on a painfully small resolution monitor, you might consider that your blocks are too large. ;) Also note that most code editors these days will highlight the opening and closing braces.

That said, both languages are reasonably pleasant to work with, so it really does come down to personal preference as to which is "better".

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

A friend can see private members. If you don't want to allow that then you'd have to work through the public or protected interface rather than friendship.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The answer is the same as when you asked last year. The organization of forums are an artifact of history, and Dani hasn't applied many changes to it in favor of the tagging system.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Because you won't learn that way.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'd suggest that you ask your teacher if he really wants you to store in excess of 8GB in memory at one time. Not only is that generally a bad idea from a design standpoint, it's not safe to assume that a computer has that much RAM to begin with. The test results will be greatly skewed when paging parts of the list in and out of virtual memory.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

"Plain text" is ambiguous. You'd need to determine what text encoding method is used (eg. ASCII or UTF-8). Not all encodings will use a leading byte order mark to tell you what you have, so some trial and error may be necessary.

If it's just assumed to be ASCII, a straight lookup of each byte against an ASCII table would be sufficient. As an example in C++:

#include <bitset>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    const char *s =
        "000000000110000001100000000000000000000001000000"
        "000100000000000001110000001001000010000001101001"
        "000100000000000000101001011001010110010000100000"
        "000000000000000001010100000000000110001000100001"
        "001011000110000001010000001000000010100100000010"
        "000000000000000000001001000000100111010000100001"
        "010000000110000101000010000101000110000101000110"
        "001000000010000000000100000000100001011100000101";

    for (const char *x = s; *x != '\0'; x += 8) {
        cout.put((char)bitset<8>(string(x, x + 8)).to_ulong());
    }
}

However, that produces garbage, so the bytes probably aren't ASCII unless your example really is random.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is that the ultimate goal? Because if it is you can take a much smaller sample of the numbers and then extrapolate an estimated search time as if the list contained billions of numbers.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yes, but nobody will write it for you.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Occurrences is easy enough with a map:

#include <iostream>
#include <map>

using namespace std;

int main()
{
    map<int, int> values;
    int x;

    while (cin >> x) {
        ++values[x];
    }

    for (auto it : values) {
        cout << it.first << ": " << it.second << '\n';
    }
}

For scale you'll need to specify. Do you mean the statistical dispersion? If so, what distribution are you looking for, if any?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

elapsed is declared as a time_point, not a duration. Read up on the chrono library here to see what options are available to you.

The code will compile like this (one of many possible variations):

#include <iostream>
#include <chrono>

using namespace std;

int main()
{
    auto start = chrono::high_resolution_clock::now();
    auto end = chrono::high_resolution_clock::now();
    int interval = 50000000;

    while ((end - start).count() <= interval)
    {
        end = chrono::high_resolution_clock::now();
    }

    cin.get;
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Well, for starters, the example value exceeds a signed 32 bit range, so you have no choice but to bump up to a 64 bit entity. Let's assume that you're reading exactly 1 billion of these values. That means you need to store 1 billion 8 byte entities, which is 7GB and change.

I strongly recommend that you consider options that don't require all of the values in memory at one time, because that much memory usage is excessive and probably unnecessary.

What exactly are you going to do with this linked list?

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

someone correct me these: 1s=1000ms?

Yup.

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

The smallest I can think of that doesn't enter the realm of IOCCC and actually opens a form is:

using System.Windows.Forms;

static class Program
{
    static void Main()
    {
        Application.Run(new Form());
    }
}

The bare minimum for a more realistic production quality application in my opinion would be:

using System;
using System.Windows.Forms;

static class Program
{
    [STAThread]
    static void Main()
    {
        AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
        {
            MessageBox.Show("Load Error: " + e.ExceptionObject.ToString());
            MessageBox.Show("An error was detected at load time", "Load Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            if (Application.MessageLoop)
            {
                Application.Exit();
            }
            else
            {
                Environment.Exit(-1);
            }
        };

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form());
    }
}

While you typically don't want to do anything that results in an unhandled exception (throwing from a form constructor or event handler, for instance), it does happen occasionally. So adding provisions in there to properly notify and exit even if the message loop hasn't started is an excellent idea.

ddanbe commented: awesome +15
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

Are you sure the previous output isn't scrolling out of the console buffer? Put a pause every hour and you'll probably see all of the output.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What version of gcc are you using? stoi exists in C++11, but that doesn't mean your compiler is sure to support it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

what is the difference between LEAP_YEAR and LEAP_COUNT?

LEAP_YEAR tells you if the given year is a leap year. LEAP_COUNT tells you how many leap years there have been up to the current year. Play with them to see what the results are.

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

I'd start by assuming that the day in the range is always 01 (the first day of the month). This isn't an actual requirement, but it simplifies things initially. One question I'd ask is if the day is beyond 01, does that month count, or do you skip to the next month?

From there you can loop through each month of each year in the range and calculate the first weekday of the month. This calculation can actually be done with minimal effort and no loops.

As a huge help for you, I'll offer something from the internals of my standard C library that finds the first weekday given a year and month:

#define LEAP_YEAR(year)  (((year) > 0) && !((year) % 4) && (((year) % 100) || !((year) % 400)))
#define LEAP_COUNT(year) ((((year) - 1) / 4) - (((year) - 1) / 100) + (((year) - 1) / 400))

const int yeardays[2][13] = {
    {-1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364},
    {-1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}
};

int first_weekday(int year, int month)
{
    int ydays, base_dow;

    /* Correct out of range months by shifting them into range (in the same year) */
    month = (month < 1) ? 1 : month;
    month = (month > 12) ? 12 : month;

    /* Find the number of days up to the first day of the month */
    ydays = 1 + yeardays[LEAP_YEAR(year)][month - 1];

    /* Find the …
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

In this case you need to use the constructor's initialization list because there's no default constructor for test1:

test2() : mytest1("test", 6)
{
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It really depends on both the library used to access the database and how the database itself works. Typically though, I'd lean toward the data going directly into the database.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yes, of course it's possible. In fact, any time you have an "is it possible?" question in C++, the answer is invariably yes.

don't be confused in database application and file oriented application .

I appreciate your vote of confidence in our ability to tell the difference between files and databases.

if yes, then how can we create database application ?

To keep things simple on yourself, start by acquiring and learning an API for the database. There are many third party libraries out there that let you use C++ and interface with SQL Server, or MySQL, or Oracle (and so on). You just need to pick a good one and learn to use it.