deceptikon 1,790 Code Sniper Team Colleague Featured Poster

isn't that possbile for somebody to bypass thos safety techniques and do it?

In the driver, sure. You can write your own "driver" that isn't limited. But if there are hardware countermeasures in place, you can't do anything without breaking out your tool set.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

In any case, there is no way anyone is going to be able to catch up to these original members....if rep is something that is important for you.

That's not entirely true. My account is just over a year old and I'm close to the top 50 in rep. However, looking at my profile clearly shows one of two things:

  • I'm not posting anything rep worthy on a regular basis.
  • Most Daniweb members just don't rep that often.

I'd like to believe that my posts are generally high quality and should deserve rep, but because of the overly discerning (or disinterested) readers, I don't get it that often and thus haven't gotten higher on the top posters list. Note that this isn't my ego talking (for the most part). The numbers from rep, votes, and endorsements over a large sample set of 3000+ posts strongly suggest a very high approval rating.

So I'm inclined to say that most of the problem with not catching up to the older members, especially those who aren't active anymore, is the reputation system simply isn't used as often as in those early days.

Another great example is mike_2000_17, whose account is only two years old and he's in the top 20. If you mosey over to his profile and look at the first page of comments, the date spread is actually almost identical to mine. Once again, high approval rating, but rep is relatively slow coming in.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Just because you have Turbo C doesn't mean you have to use stupid Turbo Cisms. Anyway, the C library already provides everything you need, most notably qsort() for sorting arrays.

On the assumption that the examples you provided are what you really want (with digits always being last), and that you desperately need examples of good code, here's one of my rare complete solutions:

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

static int compare_ascending(const void *a, const void *b)
{
    return *(const char*)a - *(const char*)b;
}

static int compare_descending(const void *a, const void *b)
{
    return *(const char*)b - *(const char*)a;
}

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

    printf("Enter text: ");
    fflush(stdout);

    if (fgets(buf, sizeof buf, stdin)) {
        int direction;

        printf("Ascending(1) or descending(2)? ");
        fflush(stdout);

        if (scanf("%d", &direction) == 1) {
            char *p;

            buf[strcspn(buf, "\n")] = '\0';

            /* Assume ascending for unrecognized values */
            if (direction != 2) {
                char temp[BUFSIZ] = {0};

                qsort(buf, strlen(buf), 1, &compare_ascending);

                /* Trim leading whitespace */
                p = buf + strspn(buf, " \t\n\r\f\v");
                memmove(buf, p, strlen(p) + 1);

                /* Rotate numbers to the end */
                p = buf + strspn(buf, "0123456789");
                strncat(temp, buf, p - buf);
                memmove(buf, p, strlen(p) + 1);
                strcat(buf, temp);
            }
            else {
                qsort(buf, strlen(buf), 1, &compare_descending);

                /* Trim trailing whitespace */
                p = buf + strlen(buf);

                while (isspace(*p)) {
                    --p;
                }

                *p = '\0';

                /* Rotation not needed for descending */
            }

            printf("Sorted result: '%s'\n", buf);
        }
    }

    return 0;
}

Please, please ask questions and learn …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

There are many ways to do something, and I've always found the four line approach to removing a newline to be excessively verbose. As such, my favorite method of removing a newline is this:

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

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

    while (fgets(buf, sizeof buf, stdin)) {
        buf[strcspn(buf, "\n")] = '\0';
        printf("'%s'\n", buf);
    }

    return 0;
}

In the above code, buf[strcspn(buf, "\n")] = '\0' will assign to the index of the newline if it's present, or the index of the null character at the end of the string if it's not present. So either you're overwriting the newline or it's a no-op by replacing a null character with another null character. This trick turns the removal of a newline at the end of the string into a one-liner.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It's a little sneaky, but you could pipe an answer to xcopy. It doesn't suppress the prompt, but it does execute it automatically:

echo F | xcopy /s /i /q /y src dst
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You select the framework version in your project properties. But if you use an installer then it will be able to point out missing prerequisites, which include the framework version. I get the impression that you're just copying the executable around.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Let's start with the easy one. Your extended properties represent an embedded string and should be quoted:

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\20130305.xlsx; Extended Properties=""Excel 14.0;HDR=YES"""
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is that possible to write a program to burn a computer literally?
A VGA,HDD

Not really. Hardware is pretty robust these days. A combination of hardware countermeasures (such as shutting down when overheating) combined with intelligent drivers will do a good job of stopping you from doing something really destructive.

I have heard of monitors being damaged by software, but that's ancient history, not anything recent. As far as hard drives, I guess you could spin it up until it overheats or something, but that's not going to be a quick kill.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

could you help clean it up some?

At a glance, I don't see anything too terrible. You seem to be mixing up an explicit declarative and automated declarative style by declaring some variables but not others, but in short pseudocode that's not a huge deal.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Let me know if it happens again and you're absolutely sure you didn't accidentally bump the button twice.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

This is highly platform dependent. What OS are you targeting?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Both answers, while correct, may be ignoring a stumbling block: a sentence is not the same thing as a string. What if the string contains a paragraph? How would you get the size of each sentence? That may be what the question is, and it's a little harder than just taking the length. You'd have to find a sentence termination character like a full stop, question mark, or exclamation point and then count characters from the beginning of the sentence until that point. Whitespace may also be considered insignificant toward the count.

I think more information is necessary to give a proper answer to the question.

string::length().

I'd actually recommend using size() instead of length(). length() is an artifact of history where the string class was accepted into the standard before the STL, and therefore didn't match the conventions despite technically being a sequence collection. It was later updated to meet sequence container requirements, but the older stuff remained to avoid breaking existing code.

size() and length() do the same thing, but size() is consistent with all other collection types, and consistency is a Good Thing™.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If the paths have different positive weights you'll want to use something like Dijkstra's algorithm for the shortest path instead of BFS. BFS assumes a universal path weight of 1 unless you make modifications.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Can you post a sample of your file?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Nonetheless, you shoud add cast to char* at lines 31 and 70 because malloc() and realloc() return argument are of type void*.

C supports implicit conversion both to and from void*. Best practice in C is not to cast, because the cast can hide a legitimate and common error of forgetting to include <stdlib.h>. However, if your personal style is to add the cast, it won't hurt anything as long as you're careful.

In C++ or C meant to be compatible with C++, you must include the cast, because C++ doesn't allow implicit conversion from void*.

tux4life commented: Thanks for including the reason ;) +13
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What kind of help are you expecting? As mentioned, we're not going to solve the problem for your or write the code for you. If you ask specific questions you'll get specific answers, but if you ask for "help" and just post an assignment you'll get no help at all.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

...what's the issue?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

feof(stdin) can be used to check if the input was read from the file or keyboard.

No, not really. It's not uncommon to signal end-of-file from the keyboard. For example, run the following program and watch it print "Yes" when you signal end-of-file using ctrl+z (Windows) or ctrl+d (POSIX):

#include <stdio.h>

int main(void)
{
    (void)getchar();

    printf("end-of-file: %s\n", feof(stdin) ? "Yes" : "No");

    return 0;
}

Further, and more distressingly, if your code is written as a filter, stdin acts as keyboard input, file input, or even piped input depending on how you do redirection from the command line. All without changing any code. Tell me, is this being run as an interactive program or is input redirected from a file?

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

char *reverse(char *s)
{
    size_t i = 0;
    size_t j = strlen(s) - 1;

    if (s[j] == '\n') {
        --j;
    }

    while (i < j) {
        char temp = s[i];
        s[i++] = s[j];
        s[j--] = temp;
    }

    return s;
}

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

    while (fgets(line, sizeof line, stdin)) {
        fputs(reverse(line), stdout);
    }

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

okay so please compile my above program in c++ broland compiler

Why should I have to make my system match yours? That's stupid. Should I also install the same operating system, applications, and use identical hardware to ensure that I get the same results as you? Why not just mail your computer to anyone who needs to run your program, because that's the restriction you're putting in place with your suggestion.

I have a better idea. How about we just not bother helping you at all? That's a lot easier than acquiring the compiler you have, installing it, and then working around whatever other exceptions are involved in making your craptastic code compile without properly fixing it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm using Turbo C++.

Turbo C++ doesn't support standard C++. You'd be wise to upgrade to a compiler that isn't over 20 years old. But if you continue to use Turbo C++, take note that you're stuck with pre-standard C++ and all of the limitations that come with it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

there this code is totally correct

Then you don't need any help...ever, because you refuse to recognize that your code is WRONG. Have a nice day.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

how to fix my code?

Look at it. You didn't post any code, so I can't tell you how to fix it. I'm not a mind reader.

and how do I find the line that it?

It's on line 103 of controlhandler.cpp, just as the debug assertion message states.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i say to you just check for exeception hindling ........

I have no idea what you mean. Your code is broken, your compiler is wrongly accepting it, and nothing will change that. Learn proper C++ instead of depending on broken compiler quirks.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

my code is totally correct ...because i compile and then post here!

Then your compiler is broken, because it's accepting nonexistent headers.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The error tells you what line it happens on, so take a look at that code, the contents of the assertion, and correct the bug. You didn't include any useful information, so I can't help more than that.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

All of you includes are depreciated.

Deprecated, not depreciated. Also, since <iostream.h> and <conio.h> were never standard in the first place, they cannot be deprecated. They're just non-standard.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

No, it's not working properly because it won't compile. Two immediate problems are <conio> and <stdlib> are not a valid headers in any era of C++, and you don't qualify for the std namespace when using <iostream>.

I can't think of a compiler that would accept this code, so I can only assume you didn't compile it. Please don't waste people's time if you're not even willing to build your own code and look at error messages.

Once you fix those problems it will compile when the conio library is fully supported (clrscr() is the usual problematic one), but the code is still hideous and brittle. With perfect input it'll work...after a fashion.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Mine is called "CLOCKS_PER_SEC". That name changes from compiler to compiler.

CLOCKS_PER_SEC is the standard macro. Any compiler claiming to implement standard C must define it. Any other macro for a similar value is not standard. Here's the same technique wrapped up in an opaque library. First, the header:

#ifndef TIMER_H
#define TIMER_H

#include <time.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef clock_t timer_t;

inline timer_t timer_get(void)
{
    return clock();
}

inline double timer_elapsed(timer_t start)
{
    return ((double)clock() - start) / CLOCKS_PER_SEC;
}

#ifdef __cplusplus
}
#endif

#endif /* TIMER_H */

And then the implementation file:

#include "timer.h"

#ifndef __cplusplus
extern inline timer_t timer_get(void);
extern inline double timer_elapsed(timer_t start);
#endif

Note that this assumes a compiler supporting at least C99 or that the code is compiled as C++ because it takes advantage of inline functions. Given that you used long long, I'm assuming that's the case. Otherwise your code isn't portable. ;) If you want it to be compatible with C90, you can't use inline and the files would be more traditional, with the header like this:

#ifndef TIMER_H
#define TIMER_H

#include <time.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef clock_t timer_t;

extern timer_t timer_get(void);
extern double timer_elapsed(timer_t start);

#ifdef __cplusplus
}
#endif

#endif /* TIMER_H */

And the implementation file like this:

#include <time.h>
#include "timer.h"

extern timer_t timer_get(void)
{
    return clock();
}

extern double timer_elapsed(timer_t start)
{
    return ((double)clock() - start) / CLOCKS_PER_SEC;
}

Using the library doesn't …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yep, there is going to be a native iOS app.

Coolio.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

There isn't one presently, and we lack the resources to develop it officially, not to mention relative lack of demand. It's on the list of things to do, just not a super high priority right now.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I think the availability of Android on different brands make it more appealing to me.

It's quite the opposite for me. Android is so fragmented that regardless of whether the OS is good or not, the variance in hardware makes it difficult to find something that works worth a damn. That's precisely why I chose to purchase an iPhone: I was sure it would work, and that's what I want in my primary phone.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

but then there must be option to revove upload from gui than rather than removing code generated after upload

Um...you mean remove the Markdown tags that embed the image using a button rather than editing the post message? I don't think that would be too big of a deal in a technical sense, but I'm not really seeing the benefit of such a feature given that you can just select the Markdown and delete it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yes deception,there are two bugs.
1) It is not applying correct reputation point.
2) On undo of upvote point,count of total upvote/downvote(i am not sure of upvote but it is there for downvote) is not changing as it should.Also list of upvote/downvote then is not showing correct.It will show list after the undo is done.

That's three bugs. ;) For #1, I'm working on it, but this is a tricky one as it seems to be intermittent. For #2 and #3 (and possibly #1), you may have to wait until Dani has some time to delve into the production database and get more information from the voting records.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If we keep on clicking the 3 alignment buttons provided to show location where image will be visible it will keep on adding.

That's the intended behavior. You attach one file, but can embed it multiple times even with the same alignment:

44e
44e
44e

Restricting each attachment to a single embed would be unnecessarily limiting, IMO.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'll be committing a fix for this display bug shortly. Pending Dani's approval it should be resolved in the next push to production.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Overflowing signed data types, while technically undefined behavior, nearly always manifests as wrapping around. So if you have the largest possible value and add 1 to it, the result will (typically) be the smallest possible value.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

noOfRows = da.Fill(ds, "tblCustomers");
No value given for one or more required parameters.

Documentation is amazing. There's no overload that takes just a DataSet and a string.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I assume by "booming" you mean popularity. In what context are we talking about? There are a lot of different places programming languages are used in very different ways, and a number of variables could affect which language is "booming" in a certain area and for certain people.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Does the device already have a driver or is he expected to write one?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

My answer remains the same. However, I've had the same task (on a much larger database than ~800 items) and simply exposed the LIKE wildcard syntax for users. If they wanted an exact match they just passed in the complete code. If they wanted an approximate match, they used LIKE syntax, such as "123%" for all codes starting with "123".

In that case the lookup was tied to a button and also a KeyPress handler because those folks were keyboard warriors, but as I mentioned before, you can use the Validated event as well.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I can still see cases where you have to validate the string though. If someone enters 'a' and you convert it to base 10 strtol() will return 0 since the conversion failed but you dont know if the conversion failed or if the user entered 0.

You're only looking at the return value. If that were the case then I'd agree that strtol() is almost as useless as atoi(). However, taking into consideration the second parameter, you can completely validate and convert all at once, then just check the results to see if there were any problems:

#include <cerrno>
#include <climits>
#include <cstring>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string line;

    while (cout << "Enter a number: ", getline(cin, line)) {
        long value;
        char *end;

        errno = 0;
        value = strtol(line.c_str(), &end, 0);

        if (end == line.c_str()) {
            cout << "Not a number\n";
        }
        else if (errno == ERANGE || value < INT_MIN || value > INT_MAX) {
            cout << "Value out of range\n";
        }
        else {
            cout << "Converted value: " << (int)value << '\n';

            if (*end) {
                cout << "Non-numeric characters detected at '" << end << "'\n";
            }
        }
    }
}

A lot of code will just pass NULL as the second argument, but that limits error checking potential. There are four cases I can think of at the moment:

  1. The end pointer is the beginning of the string, so no conversion occurred.
  2. The end pointer is not the …
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Wildcards are interpreted by the shell before your program gets a chance to touch them. If you want them passed as literals, then escape them so that they're not interpreted as wildcards:

$ python ./arch.py install \*
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The atoi() function will convert a char* into the int that it represents.

Unless it doesn't represent an int, in which case you'll invoke undefined behavior. Please forget that atoi() exists, it's totally pointless because you're forced to validate the string before passing it. The safer alternative, strtol(), does that validation for you on top of also performing the conversion you want.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The compiler can do whatever it wants. Given that at least two overloads of main() are required by the language definition, the compiler simply has to conform to that even though it doesn't need to support a general function overloading mechanism.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

There is no pass by value when it comes to a function with array as the parameter.

It's the other way around. There's no pass by reference in C, period. When passing an array, you're passing the address as a pointer by value.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Wouldn't it be even more efficient, if you calculated the size of the array inside the functions?

Aside from not being possible without enforcing some kind of structure to the array that allows calculation of its size, calculating something that's not calculated originally would be less efficient.

Since in almost every case, you wouldn't want the array_size to differ from the actual size of the array.

That's not really the function's problem. If the caller lies to it, there's really nothing it can do. Also, it would be more flexible if you don't require the size to match the size of the array because you might want to perform a partial sort:

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

#define N 10

void swap(int *a, int *b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}

void bubblesort(int a[], int begin, int end)
{
    for (int i = begin; i < end; i++) {
        int done = 1;

        for (int j = end - 1; j > begin; j--) {
            if (a[j] < a[j - 1]) {
                swap(&a[j], &a[j - 1]);
                done = 0;
            }
        }

        if (done) {
            break;
        }
    }
}

void show(int a[], int n)
{
    for (int i = 0; i < n; i++) {
        printf("%4d", a[i]);
    }

    puts("");
}

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

    srand((unsigned)time(NULL));

    for (int i = 0; i < N; i++) {
        a[i] = rand() % 100;
    }

    show(a, N);

    /* Sort the two halves …
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Well, for starters I wouldn't use the TextChanged event because that would result in a lot of hits on the database for intermediate text. For example, if the user types "foobar", you'd go back and do a fuzzy lookup on the database six times when you really only wanted one for the final string. Instead, consider using the Validated event, a KeyPress handler that looks for the enter key, or even a separate button so that you have more control over when the database is searched.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

This is older, but it's a good introduction that doesn't rely on HLA (the author's personal assembly language) like the dead tree version. Pick an assembler as well, because the documentation and communities will typically offer a lot of information. I'd recommend NASM or FASM.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

@deception: it is not caching problem i guess.check this forum.here i have received upvote but point affected is +0 although you can see mvmalderen(who upvoted ) can affect reputation by +13.In my http://www.daniweb.com/members/906747/IIM/comments it is showing +0 for the same.

I think you're confusing two different problems (as I understand the reports) which may or may not be related.

  1. Posts in the up voted or down voted lists shouldn't be there.
  2. Reputation applies 0 points when it shouldn't.