deceptikon 1,790 Code Sniper Team Colleague Featured Poster

In my mind I was using the concept of a workbook and uploading this container, rather than uploading the individual worksheets.

From an OleDB perspective, an Excel spreadsheet is just a collection of database tables (aka. worksheets) that are named something like "Sheet1$" (default), "Sheet2$", etc... So just like in any database, if it doesn't make sense to query a table, don't query the table. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Any motherboard will support Windows Vista. All of those stickers saying "Vista Compatible" or "Vista Ready" are just marketing BS. The components you need to ensure are up to spec are the CPU, the video card, hard drive size, and the amount of RAM. Those are all listed under the minimum requirements for the OS.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Did you add the TASM bin directory to your PATH environment variable? If not, you'll have to navigate to that directory to run edit.exe.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

when it comes to this kind, should bluetooth or serial (com) ports be used?

Um...it totally depends on what problem you're trying to solve and the hardware involved. For example, I don't imagine a serial port would be an option when communicating between a smartphone and an earpiece.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So for this which header file we have to include.

RTFM

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Rather than try to decipher and work with that mess, I'll give you an example of what I think you're asking for:

#include <iostream>
#include <string>
#include <Windows.h>
#include "coniolib.h"

namespace {
    win32::ConioLib conio;

    enum {
        KEY_ENTER = 13,
        KEY_ESC   = 27,
        KEY_UP    = 256 + 72,
        KEY_DOWN  = 256 + 80,
        KEY_LEFT  = 256 + 75,
        KEY_RIGHT = 256 + 77
    };

    enum {
        HILITE_SELECTED   = 433,
        HILITE_UNSELECTED = 23
    };

    int get_key(void)
    {
        int ch = conio.getch();

        if (ch == 0 || ch == 224) {
            ch = 256 + conio.getch();
        }

        return ch;
    }
}

int menu(int selected_row = 1)
{
    const int size = 3;
    const std::string rows[size] = {
        "1) Option 1",
        "2) Option 2",
        "3) Option 3"
    };

    conio.clrscr();

    if (selected_row < 1) {
        selected_row = 1;
    }

    if (selected_row > size) {
        selected_row = size;
    }

    for (int i = 0; i < size; i++) {
        if (i + 1 == selected_row) {
            SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), HILITE_SELECTED);
        }

        std::cout << rows[i] << '\n';

        if (i + 1 == selected_row) {
            SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), HILITE_UNSELECTED);
        }
    }

    std::cout.flush();

    return selected_row;
}

void execute_selection(int selection)
{
    std::cout << "You selected option " << selection << '\n';
}

int main()
{
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), HILITE_UNSELECTED);

    int selected_row = menu(1);
    bool done = false;

    while (!done) {
        Sleep(100);

        if (conio.kbhit()) {
            switch (get_key()) {
            case KEY_UP:
                selected_row = selected_row > 1 ? selected_row - 1 : selected_row;
                menu(selected_row);
                break;
            case KEY_DOWN:
                selected_row = selected_row < 3 ? selected_row + 1 : selected_row; …
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

is it going to be possible to have a connection if I create a J2ME (netbeans) as client and vb.net (2010) as the server?

Provided they both use a compatible connection method, yes. In some cases you might also need to massage the data to and from what the server expects. This is usually the case when endianness comes into play where it's different on the client than the server.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

so that the code will be something like this i think?

Close. You forgot to close the two strings:

Dim da As New OleDbDataAdapter("Select * from [" & Sheet1_EBU & "]", con)
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

This page goes into a little more detail for the same basic algorithm. It might help.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Create an overloaded operator<< to do the output:

ostream& operator<<(ostream& out, const Shoe& obj)
{
    out << shoes[i].Shoe << '\n';
        << shoes[i].Number << '\n';
        << shoes[i].ShoeSize << endl;

    return out;
}

Don't forget to make it a friend of the Shoe class, because those members are private.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Please post a complete (short!) example that I can compile.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The answer is a definite maybe. As far as being effective, if it's not effective then it's not a viable solution because it doesn't work. So there's not really any degree here, it either works for your needs or it doesn't.

Whether it's the most efficient way really depends on what exactly you want to happen. The data might support an exact or even indexed match, and in that case a LIKE clause would be relatively inefficient.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is it, generally spoken, possible, doing what '2mhzbrain' asks for, to have a kind of 'back-up' DB set up, beeing updated when the system DB- Data is edited in any way.

Certainly. What you're talking about is called database replication, or database mirroring. It does pretty much what you said: changes to the master database are committed and then propagate to the slave databases.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What are the advantages of overloading the stream extraction operator to read data from a file?

Among other things:

  • It saves the user of the class a lot of trouble in customizing I/O.
  • It saves you from having to design individual access to data members.
  • It's cleaner overall.
  • It makes your code more future-proof if there are changes (ie. you don't need to change every place the class is used).

Also I am confused what to do in main.

It becomes as simple as this, regardless of how many data members you have or whether they're publicly accessible:

if(fin.good()) 
{
    object1 = new Class[10];

    for (int i=0; i<10; i++)
    {
        fin >> object1[i];
    }
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Reverse the loop to count down from 100:

for (int i = 100; i >= 5; i -= 5) {
    System.out.print(i);

    if (i > 5) {
        System.out.print(",");
    }
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

"It's not working" is completely useless. Describe how it's not working if you want better help. But I'll point out some obvious flaws in the code:

for (int i = 5 < = 100; 1 + = 5){

This line is all borked up. A for loop has three clauses separated by a semicolon and you only have one semicolon rather than two. <= is a single operator, and whitespace between the two parts will cause a syntax error. += is a single operator, separating whitespace won't work. 1 += 5 is nonsensical, you probably meant i += 5. The line should look like this:

for (int i = 5; i <= 100; i += 5) {
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You haven't provided enough information. What kind of data? Who needs access to the data? How is the data accessed? How much of it needs to be accessible at any given time? What does "large amount" really mean?

Is this online hosting service just for storage (such as a cloud or managed internal data store) or is it a web server?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Are you physically drawing text onto the image or just overlaying text on the image at display time? The former will require some type of image processing library while the latter can be done with straight HTML/CSS assuming you have both the image and text available.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Does it really makes the process of programming faster?

That's debatable. Especially with CodeIgniter, I'm not sure it makes things faster aside from offering a bunch of libraries that save you the trouble of reinventing the wheel. But I'm not convinced that the boilerplate of a framework is any less time consuming than piecing things together manually.

However, unless you're well versed in large scale code organization, the framework will help keep things clean. PHP doesn't exactly encourage good design, so and can get out of hand very quickly.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I believe the entire code is correct, but only the way I call the push and pop function mighe be wrong.

Actually, a lot of the code is incorrect, but subtly so. The way you're using void* isn't quite right (note that void** doesn't do what you probably think it does), and when popping a generic item, you essentially can't use assignment. You'll need to copy the bytes in a generic manner:

bool pop(Elements **Stack, void *data, size_t size)
{
    Elements *elem;
    if (!(elem = *Stack))
        return false;
    memcpy((unsigned char*)data, elem->data, size);
    *Stack = elem -> next;
    delete elem;
    return true;
}

However, this opens up potential issues because you're assuming that the type of the stored data can be safely punned into a sequence of bytes. That's not necessarily true, and it's even less true in C++ when you start to use complex classes.

Finally, you have aliasing problems. For example, if the value of j changes then the value stored in the stack will change. If j goes out of scope, the stack will have a dangling pointer. You should probably store the value on the stack and not a pointer to the value. That way the stack owns what it stores. This can be done in a similar manner as copying the bytes for the pop operation.

Ignoring the punning problem, you can make things work like this:

#include <iostream>
#include <cstring>

using namespace std;

typedef struct Elements {
    struct Elements *next; …
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

After calling getchar() you need to clear the keyboard buffer of all remaining keys. Unfortunately there is no standard way of doing that.

Well, there's a standard method, but it's situational in that there must be at least one character pending in the stream if you don't want to block for input:

/*
    @description:
        Extracts and discards characters from the stream pointed
        to by in until a newline is found, end-of-file is reached,
        or a stream error is detected.
*/
void clear_line(FILE *in)
{
    if (!feof(in)) {
        int ch;

        do {
            ch = getc(in);
        } while (ch != '\n' && ch != EOF);

        if (feof(in) && !ferror(in)) {
            /*
                Preserve an error state, but remove 
                an end-of-file state if we caused it.
            */
            clearerr(in);
        }
    }
}

The problem is that you have to be sure there are extraneous characters in the stream before calling clear_line() because the following will just pause and wait for input:

int main(void)
{
    clear_line(stdin);
    return 0;
}

So you're replacing one subtle problem with another subtle problem. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I think he means that the Workbook contains many Worksheets and he needs to delete the first worksheet before uploading it to the database.

That still doesn't make much sense. Just don't upload the first worksheet.

Unfortunately I don't know anything about using Excel in C# so beyond my interpretation I can't offer anything else ^^

He's accessing Excel through an OleDB connection, so aside from a few sticking points like the worksheet name, it's just straight ADO.NET. I like to use this method as well for when installing Office on a machine is prohibitive (the "official" Excel interop requires office to be installed...), even though it's not as convenient for more advanced tasks.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

But not getting how to write.

As Momerath mentioned, you need to consider whether the class needs to implement IDisposable in the first place. If it doesn't, there's no need to complicate the code by doing so.

As for how to have a reusable disposal pattern without manually implementing it in every class, you can use a base class:

public abstract class Disposable : IDisposable
{
    protected bool _disposed { get; private set; }

    protected virtual void Dispose(bool disposing)
    {
        _disposed = true;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    ~Disposable()
    {
        Dispose(false);
    }
}

The downside to this is it basically hijacks your base class for disposal and you can't inherit from anything else. That would force you to place Disposable one level higher than your highest base class, which may or may not be something you want in your design. Once you have the base class, overriding Dispose() for class-specific needs is simple enough:

public class Foo : Disposable
{
    //...

    protected override void Dispose(bool disposing)
    {
        if (!_disposed)
        {
            if (disposing)
            {
                // Dispose of managed resources here
            }

            // Dispose of unmanaged resources here
        }

        base.Dispose(disposing);
    }

    //...
}

Now you need to ask yourself if it's worth it. All you're saving yourself is a field member, the IDisposable interface implementation, and a finalizer. All of these are boilerplate that don't really change for the traditional disposal pattern. The actual disposal part of the pattern must still be implemented …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm not sure I understand the requirement. You want to clear the Excel workbook before uploading it to the database? That sounds like a no-op, since the upload on an empty file will do nothing. Perhaps you mean clear the file after uploading? But if that's the case, why not just delete the file?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Also, in my code if you replace %c by %s in the last printf statement the compiler doesn't detect any error but the program crashes! Why is this happening?

If you change %c to %s, you must also change *buf to just buf. But neither of those changes make the loop any less wrong. Remove it entirely:

else
{
    printf("%s", buf);
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

In the following program

You forgot to include the following program.

What do the mean by that?

It means what it says. C++ doesn't stop you from walking off the end of an array:

int a[4];

// Don't do this
for (int i = 0; i < 100; i++) {
    a[i] = i;
}

This invokes what the standard calls undefined behavior, because it can corrupt adjacent memory or cause access violations if you try to access memory outside of your address space or memory that's protected in some way.

I thought arrays were not changable anyway

The size of an array is not changeable. The contents can be changed provided the array isn't specified as being read-only through the const keyword.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Those folder icons tell you the read status of the forum. When you click on the folder, it makes the forum as read, it's not supposed to navigate you to that forum. If you want to go to the forum, click on the name of it instead of the folder beside it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You didn't provide enough code. Can you post a brief but complete program that exhibits the problem?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

but i believe in case of without copy constructor it must have printed same memory address due shallow copy

That's not the case because you aren't printing the address contained by the pointer, you're printing the address of the object that owns the pointer. Change your show() method to this so that you can see the difference in addresses contained by the pointer:

void show() const
{
    cout << "integer=" << (void*)m_p << endl;
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

can anyone mention what I can do to make this program more efficient?

This is a case where I'd say you have no reason to worry about efficiency.

My problem is that I want to print only that string which is meaningful and not the garbage values. How do I do that??

getcwd() returns a string. All you need to do is print a string as normal:

#include <stdio.h>
#include <unistd.h>

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

    if (!getcwd(buf, sizeof buf)) {
        perror("Error getting current working directory");
    }
    else {
        puts(buf);
    }

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

actually turbo c/c++ is no more upadated, as borland closed the project. so it don't support the ANSI C features, System() function is the part of ansi c.

Turbo C/C++ is an ancient compiler for an outdated operating system, but it still supports C89 well enough that the system() function is available[1]. I'd certainly agree that unless you're supporting legacy code you should use a modern compiler, but claiming that system() "doesn't work" in Turbo C++ is just plain misinformation.

[1] Unless you go out of your way to find something like version Turbo C 1.0, where it was released early enough before C89 that I can't confidently talk about conformance. But I'm not aware of any way to acquire Turbo C version 1.0, so at the very least we're talking about Turbo C v2.0 or Turbo C++, both of which are reasonably close to conformant with C89.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

There's no need to be so blunt or arrogant; well that is how you are coming across to me anyway.

I get progressively more annoyed when it seems like my advice is being ignored for no good reason.

Maybe that should have been 'What ELSE would you suggest?'

Make Shoe comparable in that it has an overloaded operator<, then use std::sort() from <algorithm>. Better yet, dump Shoe_List altogether and use std::list<Shoe>.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So, I'm suppose to make a program following these guidelines.

Good luck with that.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What would you suggest?

Did my previous posts get deleted or something? I've already made two suggestions for making the code work within the restrictions of your current design.

Would it be good practice to do this?

Not really, but using qsort isn't the best practice either. Nor is having I/O in your sort() function. Honestly, if you're having trouble making things work, you should be trying whatever comes to mind to build experience instead of worrying about best practice.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What would my options be then?

Well, you could take the other route I mentioned of making the comparison functions static in your class. Then they're still members, but meet the requirements of qsort().

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So there's now way to look inside std and cout and width for myself?

You can if you want, but unless you're pretty advanced in your C++ knowledge, it'll look like gibberish.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Can you be any more vague?

uurcnyldrm commented: Being administrator does not give you the right of making fun of people. I am new and the question might be askedin a wrong way but the people who understood what I meant just helped me. I don't know what kind of mentality brings you there. You are probab +0
Begginnerdev commented: Only if the question was, "Help?" +8
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I only wish to use member functions

Then you can't use qsort().

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Test it out and see:

#include <iostream>

using namespace std;

int main()
{
    cout << "'";
    cout << "foo";
    cout << "'\n";

    cout << "'";
    cout.width(10);
    cout << "bar";
    cout << "'\n";

    cout << "'";
    cout.width(10);
    cout.setf(ios::left);
    cout << "baz";
    cout << "'\n";
}

As for where to figure these things out, a combination of a good tutorial book and a good reference book should cover most of the bases. From there it's experimentation and self study.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Maybe I am not understanding you correctly?

Clearly not, because the errors state that sortname() and sortshoesize() are both still member functions of the Shoe_List class. Take them out of the class.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I also reported a bug that I can't upload screenshots from my PC because it says "it exceeds max width * height"

How big was the screenshot?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

How can I grow the size of a char array?

That's easy, you can't. Arrays are statically sized and never change. If you want a dynamic array, you'll need to either simulate an array using pointers and dynamic allocation, or switch to a class that does it for you like std::vector.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What is the maximum allowable size for uploading files? Is this a per attachment limit or is it a per post limit?

1MB, per attachment.

When the error message (finally) comes up, perhaps it could specify what the maximum size is.

Noted. I'll have to see what's actually included in the error messages.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yes, but each horse has a different odd of winning.

That's completely irrelevant to how you store the number of wins.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Sorry, but if you want to use qsort() then the comparision functions must either be static members or non-members. A pointer to a member function means something quite different than a pointer to a static member function or non-member function, and because of this they're incompatible.

The good news is they don't need to be non-member functions, they don't depend on any object except the ones provided as arguments:

int sortname(const void *First, const void *Second)
{
    const Shoe *pFirst = (const Shoe*)First;
    const Shoe *pSecond = (const Shoe*)Second;

    return strcmp(pFirst->Name, pSecond->Name);
}
int sortshoesize (const void *First, const void *Second)
{
    const Shoe *pFirst = (const Shoe*)First;
    const Shoe *pSecond = (const Shoe*)Second;

    // Don't forget about equality
    if (pFirst->ShoeSize == pSecond->ShoeSize) {
        return 0;
    }

    return pFirst->ShoeSize > pSecond->ShoeSize ? 1 : -1;
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

a = here*;

This isn't valid syntax.

and in the function I check if here is NULL or not

You're not checking if here is NULL, you're checking if here->key is NULL. here->key is a char, so the test is nonsensical given that one of the operands is not a pointer. If here is NULL then trying to access key will result in an access violation. You want to do this:

if (here == NULL)
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'd use an array where the index represents the horse and the value stored at that index is the number of wins:

int wins[9] = {0};

// Simulate 100 races with each horse having equal probability of winning
for (int i = 0; i < 100; i++) {
    ++wins[rand() % 9];
}

// Display the formatted results
puts("Horse\tWins");

for (int i = 0; i < 9; i++) {
    printf("%d\t%d\n", i + 1, wins[i]);
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Clear your parameters collection when the values change, you're doubling them up and the variable name is a unique key:

while (readerReference.Read())
{
    cmd_Insert.Parameters.Clear();
    cmd_Insert.Parameters.AddWithValue("@emp_login", readerReference.GetInt32(loginIndex));
    cmd_Insert.Parameters.AddWithValue("@emp_dom_code", readerReference.GetInt32(DomCodeLoginIndex));
    cmd_Insert.Parameters.AddWithValue("@emp_domain", readerReference.GetString(dom_domain));
    cmd_Insert.Parameters.AddWithValue("@emp_surname", readerReference.GetString(emp_surname));
    cmd_Insert.ExecuteNonQuery();
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The file sizes were 1,351,013 bytes and 304,896 bytes.

1MB is the size limit for attachments, so the first one is too big.

They were chm files.

And chm isn't a supported upload type. Try zipping those files and uploading the archive. It looks like the problem with the files not uploading in IE was simple lack of support, though I'm a little concerned that the errors weren't showing up. We definitely trap attachment errors and list them on the page.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I am currently reading a C text book which has chapters dedicated to file I/O but there is no mention of reading integers from a binary file.

Look up the fread() function for a simple start.