deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Are you trying to get answers to your own questions?

To date I've always been able to find my own answers in other ways. I'll usually start with reading the manual, then a web search, then asking coworkers, then calling support if that's relevant, and experimentation or reverse engineering as a last resort. I would lump the answers I might get by starting a thread here as being included in the web search since the chances of asking a truly unique question are vanishingly small. So asking questions on Daniweb doesn't strike me as likely to be more effective than my current algorithm for solving a problem.

What value do you get from helping people?

I've learned a lot by teaching. Probably one of the best ways to solidify one's own knowledge is teaching it to others because that makes your misunderstandings and gaps all the more apparent.

Has DaniWeb helped you forward your career?

I've gotten jobs from employers who were impressed by my posts here, so that's a big yes.

Have DaniWeb community members evolved into quality online friends?

I'd like to think that a few of you see me as a friend by now. ;)

Have you ever done business with people you met on DaniWeb?

Well, given that the business I've done has been with you, Dani, I can't exactly say no. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

This is easy to find information. Where did you search before posting here?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I don't really understand, why would the sorted array be advantageous?

Take a hash table, regardless of implementation, and print out all of the items in sorted order. You'll discover that it's not as simple as just traversing the table, and that's the first advanage that comes to mind for a sorted array, where it is as simple as just traversing the array.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Realistically, a sorted array would be advantageous if you want to get a sorted listing of items, or do a ranged search or anything except an exact match. If all you're doing is searching onesie twosie, the hash table is conceptually faster. In practice the array and a binary search may be faster due to caching though.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

how do I keep on comparing it til the stack is null or the precedence don't hold true anymore?

Use a loop. ;) The algorithm should look something like this:

for each character
    if whitespace
        next
    else if not an operator
        append the current character to postfix
    else
        until the stack is empty or the top value has greater or equal precedence
            append the top item
        push the current character to the stack

until the stack is empty
    append the top item

Which when converted to C++ might look like this:

std::string InfixToPostfix(const std::string& infix)
{
    std::stack<char> st;
    std::string result;

    for (char ch : infix) {
        if (isspace(ch))
            continue;
        else if (!IsOperator(ch))
            result.push_back(ch);
        else {
            while (!st.empty() && ComparePrecedence(st.top(), ch) >= 0) {
                result.push_back(st.top());
                st.pop();
            }

            st.push(ch);
        }
    }

    while (!st.empty()) {
        result.push_back(st.top());
        st.pop();
    }

    return result;
}

This is all without handling parentheses, of course, but your code didn't either.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Does the constant have to be private? It seems silly to require it to be private and also require it to be accessed directly from outside of the class.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Does the following code make p as a null pointer

Yes. Static variables are zero initialized, which for pointers means the equivalent of NULL. You can verify that this is the case (other than reading the standard documentation) with a simple test:

#include <stdio.h>

static int *p;

int main(void)
{
    if (p == NULL)
        puts("It's NULL!");

    printf("Zero initialized address: %p\n", (void*)p);

    return 0;
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Dudes ...use getline and put . As delimiter

How does '.' as a delimiter enforce field widths of 20 characters?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Please read our rules concerning homework. Simply posting your homework question is a good way to have the thread deleted.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It looks straightforward. Are all records separated by multiple blank lines? Really all you'd be doing is writing an algorithm to read a record and write some of the data onto a single line of output. My very first programming job was writing report filters almost exactly like that in C++.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Love it! Such a simple thing, but seeing who solved it and when is handy info.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I don't why I am asking this maybe to gain your opionions... though I am not asking daniweb to change it's colors... but aside from DANIWEB being purple what other color should be it's theme color?

At one point several years ago each forum category had its own color, such as red or green. It wasn't memorable though; I honestly can't remember the color of the software development forums, and I spent far too much time on them...

As for what the main color should be if it weren't purple, maybe steel blue?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Nobody will read four thousand lines of unformatted code to tell you what you did wrong, but judging by the errors I'd wager that formatting it will highlight the error promptly and obviously.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Anyone willing to assist?

Willing yes, but not capable with such a vague description of what you want to do and the problems you're having.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

By dropping down a level, you need to handle lower level concerns like string termination:

ob.read(word, sizeof word - 1);
word[ob.gcount()] = '\0';
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Anytime you get a large negative number, there are two things to check straight away:

  1. Any uninitialized variables in your math.
  2. Any out of bounds indexing or invalid pointers (they can corrupt other variables).

Either way the problem isn't in rand(), it's your code doing something funky.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

my question was why does it gets inialized during COMPILE time only?

The zero initialization is historically due to where static variables were stored in the executable image. They were typically placed in the BSS segment of the image, which typically included zero initialization of memory blocks. The C standard then blessed the semantics of zero initialization for statically linked objects, and we're where we are now.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It's not compulsory.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

2D arrays aren't a single entity like in some languages, they're arrays of arrays. What you're actually trying to allocate here is a pointer to size arrays of size int, and the destination type needs to reflect that:

int (*b)[size] = new int[size][size];

This is assuming size is a const variable or macro, otherwise you're trying to do something that's not legal in standard C++: define an array with a size that isn't a compile time constant.

I'm going to go out on a limb and assume that what you really want is a fully dynamic simulated 2D array, in which case you should either use the std::vector class or follow this pattern for allocation:

int **b = new int*[size];

for (int i = 0; i < size; ++i)
    b[i] = new int[size];

And this one for release:

for (int i = 0; i < size; ++i)
    delete[] b[i];
delete[] b;

But std::vector is strongly recommended unless you're just trying to learn how pointers and dynamic memory work.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It's a program with a menu of user options in the interface that guides what the program does. There's no magic or complex logic here, it's just a simple menu.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The loops are a red flag for me because they count from 1 to n instead of from 0 to n-1. C# arrays are zero based, so even if n represents a safe limit for the array, you're still looking at an off by one error.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Do you guys have any advice for me?

Probably nothing you haven't already heard.

If you could do it over again what would you have done differently?

Most certainly, I would have. If I knew what I know now, I'd probably not have gone the IT/developer route and would have kept it up just as a hobby.

What should an adult, who is changing careers and looking to do well in IT know?

Hmm, I'd probably say that you should try to leverage your age as "maturity" to compete with younger people fighting for the same jobs. Employers tend to look kindly on folks who aren't hot headed and ready to dive into potential risks without due forethought. ;)

You're in a sweet spot where you seem old enough to think before you act, but young enough not to be stubborn and set in your ways. It's a good place to be, in my opinion.

Be prepared to learn a lot and be wrong a lot. IT is fast paced and constantly in flux.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Automagic synthesis of a default constructor is disabled when you provide any explicit constructor. If that explicit constructor has arguments and not all of them are defaulted, then your class will not support a default constructor unless you explicitly define one.

Your class has a seven argument constructor, so the default construction syntax won't work. There are quite a few problems with your code, but that's the exact cause of the error you're receiving.

If you describe what the program is supposed to be doing, I may be able to help you redesign things to work better.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

This article may help you with using the directional keys. Turbo C supports the getch() based solution. Note that it only describes how to capture and respond to those keys. What you do in the response is where most of the real work lies. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Network places isn't a directory, it's more of an ad hoc listing of visible network devices. You can get a similar listing with the net command: C:\>net view. Or use the /? argument to get a summary of arguments for net.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

No. Daniweb is not your personal homework service. We require that you make an honest attempt to solve the problem. Please read our rules.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If you can run the C++ program and see output in the command prompt, it's working and the problem is in C#.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I moved this thread to C# because the fact that the process you're running is written in C++ is completely irrelevant to the question. I'm not familiar with ProcessStartInfo.RedirectStandardOutput, so I'll defer to others on whether you're using it correctly.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Rather than down vote my post, please explain how those solutions are unsuitable for you. Did you even follow my link?

Edit:
I guess you really didn't want help after all. Thanks for saving me all of that time. By the way, I deleted your previous duplicate thread of this question because you clearly abandoned it.

Shft commented: No, Because I don't care if you're an administrator, that doesn's make you different from anybody else, and you're really grinding my gears by deleting my last post +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

How are you calling the C++ program? Is it C++/CLI and a .NET assembly or are you using COM? Or are you just calling a program that happens to be written in C++?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Because nobody answered the first one!

That's not a good reason when your first thread is still on page 1.

I really need help with coding the software!

If you're depending on random people on a forum to complete your project, you'll fail. Guaranteed. But I'll bite. Do you know anything about sockets? Your question suggests not, so I'll link you here. And your ability to ask an answerable question is also severely lacking, so I'll also link you to here.

Please read both links in their entirety and learn what they have to teach. If you post another thread asking the same question, I'll delete it as a duplicate.

Shft commented: No...No... Miser socket no es here, you go to other daniweb +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Why did you create a second thread for the same question?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

My point was to make the op think about what was going on and explain it as an exercize in working out the problem.

That's a pointless exercise when the book explains what the problem is and why it's a problem. The question was why does the code appear to work correctly when it's provably wrong? It's been a while since I've read that book, but I don't think the author went into detail about how undefined behavior includes expected results. Actually, if I recall correctly, he made some pretty egregious assumptions about the environment.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Seems okay on my end. What browser and OS? Did you try clearing your cache and doing a hard refresh of the page?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I doubt you NEED it, you just think you need it. But my alternative answer still stands. I ran that search and the pretty much every hit on page 1 was a viable solution.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The easy solution is to not use gotoxy(). It's a Borland holdover from the days of yore where 640K wasn't a laughably small amount of memory. Get with the times and write a real GUI if you need more control than the command prompt provides.

Alternatively, you can search google. Beginners too entrenched in their Turbo C++ ways have asked the same question countless times.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You're using the %s specifier, which is whitespace delimited. It won't stop reading when it sees a comma. Try this:

#include <stdio.h>

int main(void)
{
    char buf[BUFSIZ];

    while (scanf("%[^,\n]%*c", buf) == 1)
        printf("'%s'\n", buf);

    return 0;
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Please post a small program that exhibits the problem and a sample of your CSV file. scanf() format strings can be tricky, and scanf() is usually unsuitable for true CSV, but if it's just a naive comma separated format without embedded commas, you can get away with using scanf().

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You say obviously wrong. In what way?

It is obviously wrong, and undefined, though I'm not sure the book specifies "undefined". Look at the size of the array, then look at the loops.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

One possible effect of undefined behavior is producing the expected result. That's why it's so difficult to explain to someone whose program is working that it's broken and wrong.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I personally feel that Visual C++ 6 was the best , MS ever produced.

If you ignore the bugs and absolutely horried support for standard C++. To date, the only compiler I've had to hack (mostly standard library files) to make it usable is Visual C++ 6. Hardly the best Microsoft ever produced. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

At least you waited a whole 11 hours before complaining about not getting help. Keep in mind that the forum is a volunteer effort. If you want to guarantee immediate help, you'll need to find a paid support service.

I also notice that two of your articles are not trivial questions (fewer people are likely qualified to help you), and the third is a job offer.

Clearly you have unrealistic expectations.

happygeek commented: well said sir +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
void foo(void); // Declaration
void foo(void); // Declaration (redundant but legal)

void foo(void) {} // Definition
void foo(void) {} // Definition (redundant and illegal)

A function definition is where you give the function a body. A declaration has no body and only lists the function signature (return type, name, and parameters). So the statement could be simplified to "a function can only have one body".

saurabh.mehta.33234 commented: thankyou for your simple explanation +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Recursion is very inefficient for the computer, but in terms of programmer time it is efficient.

It depends. Pretty much any compiler these days will perform tail recursion optimization such that if you only recurse once and it's the last thing you do, the recursion will be converted to iteration internally. So this would likely be just as efficient as a non-recursive implementation because it uses tail recursion:

int factorial(int n)
{
    if (n <= 1)
        return 1;

    return n * factorial(n - 1);
}

For more complex recursive algorithms that cannot fully use that optimization, the overhead of stack frames may not be as significant as your teacher is implying. When recursion is used properly (binary search is a good example), the depth of recursive calls is kept to a minimum. The overhead is also far less significant than it used to be, such that recursion is often efficient enough except for the most persnickety of realtime applications.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So what do you do to pass the time at work when it becomes a bit quieter and you have nothing else to do?

Posting on Daniweb, working on Daniweb's code, surfing the web, personal projects, etc...

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

From what I understand is Java is mostly understanding, implementing, and manipulating algorithms.

That's universal, it's not unique to Java.

To me this seems like I just used a simple algorithm to obtain the desired result.

In my opinion, a good professional would start with the simplest algorithm that meets requirements and only make it more complex as necessary. While it might seem inefficient, for example, I'll often use a very simple linear search on collections that are unlikely to be large enough to warrant something "faster".

So in your professional opinion does this look professional and efficient?

Well, it's poorly formatted, so that makes it unprofessional. It's not inefficient, but it is one of the worst possible hashing methods[1], so I'd say it's an unprofessional function because it fails to meet the requirements of your typical hash function: fast and minimal collisions.

[1] See additive hashing on this website.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Neither of those are an equivalent to PHP's explode(). To do it thoroughly you'd need to include all of the logic for the limit and any edge cases that affect the result. I hacked this up pretty quickly from the PHP manual's definition, but it should be close:

#include <cstdlib>
#include <limits>
#include <stdexcept>
#include <string>
#include <vector>

std::vector<std::string> explode(
    std::string delimiter, 
    std::string source, 
    int limit = std::numeric_limits<int>::max())
{
    // PHP returns FALSE in this case, but C++ doesn't handle variant types well, and a
    // reasonable facsimile of FALSE is tricky with std::vector<>, so we'll just throw.
    if (delimiter.empty())
        throw std::invalid_argument("Empty delimiter in explode()");

    // Sanitize the limit to something meaningful
    if (limit == 0)
        limit = 1;

    std::vector<std::string> result;

    // Handle the simple case of zero delimiter matches
    if (source.find(delimiter) == std::string::npos) {
        // PHP returns array() if limit is negative, array(source) if limit is positive
        if (limit > 0)
            result.push_back(source);

        return result;
    }

    std::vector<std::string>::size_type begin = 0;
    std::vector<std::string>::size_type end = 0;

    // Explode up to any positive limit, exclusive
    while (end != std::string::npos) {
        if (limit > 0 && result.size() == limit - 1) {
            // PHP populates the last element (ie. result[limit - 1]) with the remaining 
            // string when limit is positive and less than the number of total tokens.
            result.push_back(source.substr(begin));
            break;
        }

        /*
            Conventional C++ manual string tokenization.
        */
        std::vector<std::string>::size_type substr_len = std::string::npos;
        std::vector<std::string>::size_type next_tok = std::string::npos;

        end = source.find_first_of(delimiter, begin);

        if (end != std::string::npos) {
            substr_len = end - begin;
            next_tok = …
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You need to validate the password completely, then display the output:

#include <stdio.h>

int main(void)
{
    const char *pass = "letmein";
    int ch; // int, not char!

    while ((ch = getchar()) != '\n') {
        if (ch != *pass++)
            break;
    }

    if (*pass)
        puts("Invalid password");
    else
        puts("Welcome!");
}

Note that your code contains a bug as well. ch should be declared as an int to ensure that EOF (a value guaranteed to be outside the range of valid characters) is properly handled.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

As far as what the requirements are: a good candidate is an expert in their field

That's not a requirement, though active members who meet the other requirements have a very strong tendency to also be experts who give excellent help rather than receive it. As an example, we were far more likely to single out someone like mike_2000_17 as a potential candidate because he is an expert. He posts very often with confidence and because of that was able to inadvertently show off traits that we look for in moderators.

It is an invite-only thing :)

Kinda sorta. I have it on good authority that Narue originally requested to become a moderator. The usual debates amongst the team ensued, but there wasn't an initial recommendation; Narue started the process by asking, and it turned out well. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Jim you could always try something like http://ideone.com/ to help with the guessing, no clue if it is any good though!

It's not up to any serious development, but for quickie test programs it's quite useful. I often use it for PHP because with my dev environment the alternative is awkward at best. :)