deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It looks like the HTML entities weren't properly converted for display.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It places a value on the top of the stack. The equivalent would be:

; push [arg]
sub esp, 4
mov esp, [arg]

Conversely, pop will do the opposite:

; pop [arg]
mov [arg], esp
add esp, 4
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Google it. You strike me as especially lazy, to the point of not even answering simple questions from those trying to help, so I'm not encouraged to write an example for you.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

And why do you want it? I'm guessing the projects on places like sourceforge are too complex or otherwise unsuitable for your needs, so it would be helpful to understand what your needs are.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What's your definition of "cool"? And why do you want such a program?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Try to remember your first steps.

Sorry dude, but you'll get no sympathy from me on that front. The resources you have at your disposal would have given me a woody when I was first learning.

This is not an answer: "Use loops".

Did you learn anything at all from the code I provided? You pass the size of the array from the function that it was declared in because array parameters aren't actually arrays, they're pointers, and the size information is lost.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I think that's quite enough of the "me too" joke offerings to do it for money.

nitin1 commented: you are also well in cracking jokes, ;) +2
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I can't figure out how to do it.

You know how to get the size of an array, and you know how to pass arguments into a function. Put those two together and it's easy to see why one might think you've turned your brain off:

#include <stdio.h>

void foo(int size)
{
    printf("%d\n", size);
}

int main(void)
{
    int a[10];

    foo(sizeof a);

    return 0;
}

Thanks all for your "solutions".

With that attitude, you won't get any more. Best of luck with your homework.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Mask just the low byte after shifting and you'll get what you want:

int red = (p >> 16) & 0xff;
int green = (p >> 8) & 0xff;
int blue = p & 0xff;

Coincidentally, I did this very thing today while writing an image skew detection algorithm.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm willing to be that count and totalwords are both int too, which means your division is performed in integer context. If the division results in a value less than zero, the precision is ignored and the result will be 0. You want something more like this:

int wordpercent = (int)((count / (double)totalwords) * 100)

This forces the division into floating point context, which retains precision so that it isn't lost before the multiplication step.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The exact same way you do there.

Wait. You're saying that the syntax and semantics of loops don't change from function definition to function definition? That's just crazy talk. ;p

WaltP commented: You know me -- crazeee +14
nitin1 commented: yes! i also know you ;) +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

By invitation only :)

Though there is at least one precedent where someone has asked to join the moderation team and that started the process.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Ahh but if I do that, what happens when I access the values in the body?

If the parameter names are the same as the data member names, the parameters will hide the data members when unqualified. This ambiguity doesn't exist in the initializer list, and it can be corrected in the body by qualifying with this:

this->x = x;
this->y = y;
Point(this->x, this->y); // But Point(x, y) works too since the values are the same
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The choice and reason are both trivial: pick the language you're most comfortable with, because it's easier to stand up a working project quickly when you're not fighting with your tools.

sss93 commented: Thanks and yea I totally agree with your statement +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Clear yet?

With one post 2 years ago asking for other people to do their thinking for them, I'm willing to bet that the OP has long since failed. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

floating point constant cannot be stored in structure through scanf

Sorry, but that's incorrect.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

no deceptikon i have done this task in past and it worked for me actually the output will be like dis

Sorry, I'm having trouble deciphering the meaning of this sentence. Are you sure you're responding to something I said? If so, please quote it. Also, it would be nice if you used full sentence English rather than txt speak. Is it really so hard to type "this" instead of "dis"? Or "are" instead of "r"? Or "you" instead of "u"?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

can anyone tell me if there is such thing as 64 bit assembly

Yes.

if so can you give me an assembler

MASM, NASM, and FASM all support 64-bit instruction sets.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You'd get better results just posting your music on YouTube.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

@deceptikon Can u plz post the corrected code??

No. You wouldn't learn squat if I did the work for you.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Plz tell me where i am going wrong..

Start with the fact that you're double incrementing both ptr and i. Note how the increment clause of the for loop increments both of them, but in all other paths of execution in the body you still increment both of them.

Fix that and then trace through the execution in a debugger to see how your casing logic is actually working compared to how you think it works.

hello u can try like this where ascii value of a space is 32

Why are you using 32 when there's a character literal (ie. ' ') that doesn't depend on ASCII or ASCII-compatible character sets?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You can, but my immediate question is why do you want to do so? There has to be a purpose for any level of indirection, otherwise it's just pointless complexity.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

@deceptikon: Is there a way to find out if there were any stickies before the move to the new forum?

Yes indeed. It appears there was one sticky as of July 2011, which I've re-stickied.

pritaeas commented: Thanks. +0
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I find it odd that the implementation supports streams yet not completely. If the hardware couldn't handle stream behavior (presumably this is an embedded platform) then excluding that part of the library entirely would be expected. Rather, I don't recall any clauses in the ISO standard that say tellg() may be conditionally supported in the presence of an otherwise working iostream library, even for freestanding implementations.

But to the matter at hand, istringstream is really doing nothing more here than breaking the line down into fields and converting those fields. Since you already know that the >> operator is whitespace delimited, you can get the same value as stream.tellg() by counting delimiting whitespace for the first four fields:

getline(file,line);
{
    std::istringstream stream(line);
    UINT32 file_pos, fields;

    stream >> first >> second >> third >> forth;

    for (file_pos = 0, fields = 0; file_pos != line.size(); ++file_pos) {
        // Assuming fields are separated by only a single delimiter
        // and the line doesn't begin with whitespace. These are
        // fairly easy to handle, but I'll leave it to you.
        if (isspace(line[file_pos])) {
            if (++fields == 4)
                break;
        }
    }

    fifth = line.substr(++file_pos , line.length() - stream.tellg());
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I am attempting to find a pivot point in a sorted array for example { 1 2 4 5 9 } might become { 5 9 1 2 4 }.

That seems simple enough. The array is already sorted, so just start swapping everything from the median:

for (int i = 0, j = median; j < n; ++i, ++j)
    swap(&a[i], &a[j]);

This works perfectly for even numbered arrays, but for odd numbered arrays the median itself is an outlier. The swap trick from above will work for all but the median, but then you can shift the right half of the array one spot to the left and plug the median in at the end to finish things up:

int save = a[median];

for (int i = 0, j = median + 1; j < n; ++i, ++j)
    swap(&a[i], &a[j]);

memmove(&a[median], &a[median + 1], (n - median - 1) * sizeof *a);
a[n - 1] = save;

Easy peasy. :)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

This is obviously allways defined, so I assume the purpose is to comment out or remove the define if done debugging.

Yes. This isn't modularized as a library, though that would be relatively simply by adding a header, it's just a single file for exhibition purposes. The whole TEST_DRIVER preprocessor stuff is really just there to highlight that it's a sample driver with some simple test data.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is this true or can I actually do this in C++?

One of the reasons why this is reasonable in Java is the lack of default arguments. In C++ you can do it all with one constructor:

Rectangle(int width = 0, int height = 0, int x = 0, int y = 0)
    : width(width), height(height), x(x), y(y)
{
    // Nothing necessary in the body
}

Note that I swapped x and y with width and height. For one thing I think it makes more sense conceptually, but also to support the second variant of Rectangle() from your Java code more easily.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Encoding and decoding functions for RFC 4648 compliant base-64. The code is written in standard conforming C11 and backward compatible with C99 (pre-C99 is not supported without code changes).

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

it makes an assumption that all odd numbers are prime numbers (d += 2) if I understand well... correct me if I am wrong...

It's the other way around. The function makes the assumption that all even numbers are not prime, which is a safe assumption given that 2 (the only even prime) is given special treatment. The d += 2 part of this algorithm is skipping over even numbers (excluding 2) because they're guaranteed not to be prime factors.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The problem is that there are too many open files.

That's indicative of a design flaw. You can check the value of FOPEN_MAX (defined in stdio.h), and it's probably rather large for your implementation. If you exceed that value, you probably need to consider why you have so many files open at once and think about ways to avoid that.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is it any ad or only certain ads that cause the problem?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Thanks for input, my main concern was that of runtime performance.

Unless you have very good reason, I'd say disregard performance in general and code for clarity. Don't go out of your way to use inefficient constructs, of course, but also don't go out of your way to optimize your code without plenty of runtime evidence that it's too slow and a cost to benefit justification for making it faster.

Too many people worry about performance when it makes no sense to do so. A few examples I see among the inexperienced are:

  • Worrying about the performance of individual expressions. Chances are very good that you're not working in an environment where replacing multiplication with shifting, or modulo with bitwise AND, will make one whit of difference.

  • Optimizing CPU bound operations when the program is IO bound. It doesn't matter how fast your search algorithm is if the program spends 99% of its time waiting for user input or displaying output. Optimize the perceived performance to the user in interactive programs, because that's where it matters.

  • Worrying about imaginary performance problems. This thread is one such example. For some reason you interpreted name qualification as a threat to runtime performance, which is completely nonsensical to those who understand how it works under the hood.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The using directive pulls in every visible name from the namespace while the namespace qualified name is visible only for that single use of only that name. Obviously if your goal is to avoid naming collisions in multiple namespaces, a using directive is the worst possible choice and a qualified name is the best possible choice.

However, that doesn't mean qualified names are always better. It's fairly obviously that qualified names are more verbose. You can also limit the scope of the using directive. The following is much less likely to clash names than a using directive at file scope:

void foo()
{
    using namespace NameSpace;

    ...
}

Finally, there's a third choice in the using declaration:

using NameSpace::Method;

This is something of a combination of a using directive and a qualified name in that you're only pulling in that single name, but you're doing so for all uses of the name after the declaration rather than just a single use.

Such as, are there any performance gains with one or the other etc...?

Don't concern yourself over performance here. If there's a difference, it'll be negligible and limited to compile time.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Have you read the documentation for the XmlDocument class? It has methods for doing everything you want.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You forgot to give us your teacher's email address so that we can submit your homework after we've done it. :rolleyes:

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The download you're looking for is mingw-w64-v2.0.6.tar.gz, here.

It looks like MinGW-64 is distributed as a gzipped tarball and there's not a Windows installer, so you'll need to extract it. I use WinRAR to handle extraction of gzipped tarballs, you may consider that too. Once the package is extracted (note I'm going by flakey memory here), you'll basically need to manually create the MinGW folder and set up paths. As I said, there doesn't appear to be any installer, so that stuff won't be done for you.

Then you'll install Eclipse and under its compiler settings point it to the requisite files in your MinGW folder (ie. gcc.exe for the compiler, gdb.exe for the debugger, as.exe for the assembler, ld.exe for the linker). I don't use Eclipse, so I'll let someone else chime in with details.

As an alternative if you don't need full 64-bit compatibility, you can just install the 32-bit versions, which will probably be much simpler given existing installers and instructions.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Oracle is still widely used. Four of my biggest clients use Oracle as their back-end, and not knowing Oracle or SQL for Oracle would have lost me those accounts.

And also is this job called Database Developer?

That might be one job title, sure.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Wow, could you get any lazier?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

wrong d=25 is not prime!

How is it wrong? The program doesn't say that 25 is prime.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i mean my qyestions are not such a big thing to solve by people like here.

There could be any number of reasons people wouldn't answer a question. Reasons that come to mind in my case:

  • They don't know the answer.
  • The answer is too involved and they're not interested in spending the time.
  • They know the answer but aren't sure it's 100% correct.
  • They know the answer but aren't sure how to explain it.
  • They aren't confident in being able to field subsequent questions.
  • The topic isn't of interest to them.

The last one is a biggie with some of your questions. For example, you've recently started learning about cryptography. I know about cryptography (because my job requires it) but don't find it especially interesting, so I don't bother answering questions about it. It's much like I know Java, but don't spend time on the Java forum because I don't care for that language.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Actually, I'm not regulars of PHP forum, and I also don't know the language.

If the thread focuses on language/library stuff then at least someone who might be seen as an expert would have to write it. For example, to write one of the stickies you mentioned (Flushing the input stream) the author would need expert level knowledge, as I'm sure most would agree Narue has.

If the thread focuses on best practice for posting, it would be best for a regular to write it because regulars are more likely to understand both the official rules and unwritten guidelines followed by the community.

I thought it would be nice to have sticky's in PHP to.

Stickies for sticky sake aren't a good idea as they'll clutter the forum. That's not to say that I disagree with some good ones in the PHP forum, but since they haven't been written yet I'm not convinced that the PHP forum folks are interested in having them. That forum is very active, after all.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Sticky threads are nearly always contributed by regulars of a forum. So if you want a sticky, start a thread with whatever topic you want stickied, then make a moderator aware of it. :)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

when i post any post , then hardly 1 reply is there

That's less an artifact of which forum you post in than it is the content of your post. Perhaps you asked a question that very few people are qualified to answer or interested in answering.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Someone asked this exact question today. Was it you? :P

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The forum you're looking for is called Computer Science.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

For example using Wikipedia's traversal result (F, B, A, D, C, E, G, I, H), the execution logic might go like this:

F, B, A, D, C, E, G, I, H
^
F, B, A, D, C, E, G, I, H
^  ^
F, B, A, D, C, E, G, I, H
^     ^
F, B, A, D, C, E, G, I, H        A
^  ^  *
F, B, A, D, C, E, G, I, H        A
^     *  ^
F, B, A, D, C, E, G, I, H        A
^     *     ^
F, B, A, D, C, E, G, I, H        A, C
^     *  ^  *
F, B, A, D, C, E, G, I, H        A, C
^     *     *  ^
F, B, A, D, C, E, G, I, H        A, C, E
^     *  ^  *  *
F, B, A, D, C, E, G, I, H        A, C, E, D
^  ^  *  *  *  *
F, B, A, D, C, E, G, I, H        A, C, E, D, B
^  *  *  *  *  *
F, B, A, D, C, E, G, I, H        A, C, E, D, B
^  *  *  *  *  *  ^
F, B, A, D, C, E, G, I, H        A, C, E, D, B
^  *  *  *  *  *     ^
F, B, A, D, C, E, G, I, H        A, C, E, D, B
^  *  *  *  *  *        ^
F, B, A, D, C, …
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Unless you're forced by a very backward teaching institution to use Turbo C, or you're maintaining legacy code that must be compiled using Turbo C, GCC (a recent version) is very clearly better.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The last two loops should be nested:

for (int middle = 0; middle < 0.5 * height; middle++) {
    for (int middle = 0; middle < height - 1; middle++)
        cout << ' ';

    cout << '|'<< '|' << endl;
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You don't need Office to access the provider, just the redistributable.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Also i would like to know the other methods of doing this.

My solution would probably be a double reversal. First reverse the entire string character by character (ie. "daS mA I"). Then go over the string again and only reverse each word. The end result is that the word order is reversed, but the characters in each word are normal (ie. "Sad Am I").

I'd also tighten up the definition of a word to just alphabetic and numeric characters. That way any punctuation can be ignored in the second step and retains the original position. But that's straying a bit from the problem definition and may need tweaking if it's not the desired result:

#include <ctype.h>
#include <stdio.h>
#include <string.h>

void reverse_string(char *begin, char *end)
{
    while (begin < end) {
        char temp = *begin;
        *begin++ = *--end;
        *end = temp;
    }
}

char *word_begin(char *s) { while (*s && !isalnum(*s)) { ++s; } return s; }
char *word_end(char *s) { while (*s && isalnum(*s)) { ++s; } return s; }

int main(void)
{
    char s[] = "The quick brown fox jumps over the lazy dog";
    char *begin = s, *end;

    reverse_string(s, s + strlen(s)); /* Reverse everything */

    /* Reverse individual words to restore them */
    while (*begin) {
        begin = word_begin(begin);
        end = word_end(begin);
        reverse_string(begin, end);
        begin = end;
    }

    puts(s);

    return 0;
}
nitin1 commented: good approach uses! +0