deceptikon 1,790 Code Sniper Team Colleague Featured Poster

<grammar Nazi hat on> "intergers" is correctly spelled "integers". </grammar Nazi hat on>

<über pedantic mode>

You need to wear your spelling Nazi hat because using the correct word in the correct context with incorrect spelling is not a grammatical error, it's a spelling error.

</über pedantic mode>

:D

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yes.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Most likely what you wanted was this:

data[i] = data[i] + m.data[i];

Since the error suggests you don't overload the subscript operator to get the contents of data, you need to touch m's copy of data directly.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What is the best game you played so far in your entire life?

What's the criteria for "best"? I'd probably list games that I come back to on the regular and still find fun or engaging for long periods. These come to mind immediately:

  • Everquest II
  • Elder Scrolls: Oblivion
  • Fallout 3
  • Chrono Trigger
  • Chrono Cross
  • Final Fantasy I
  • Final Fantasy VII
  • Super Metroid
  • Megaman X
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm only new around here, but it seems like a good community where something like the current IRC channel could be put to good use.

Agreed. The problem is that we have trouble convincing enough people to hang out on the IRC channel. It's so inactive that anyone who tries will end up leaving, never to return, in short order. Such is the attitude of instant gratification, I think. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i need computer programming code picture for my work

Do you regularly ask other people to do your work? If so, I'm greatly relieved that you're not one of my coworkers.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Well, the error says that your query is wrong, so that's a good place to start. ;) My guess would be because Access is having trouble parsing "Tel number", and surrounding it with brackets would fix the problem:

string myQuery = "INSERT INTO Parent( Name, Surname, Address, Postcode, [Tel number], Email, UserName, Password) VALUES ( '" + TextBox1.Text + "' , '" + TextBox2.Text + "' , '" + TextBox3.Text + "' , '" + TextBox4.Text + "' , '" + TextBox5.Text + "' , '" + TextBox6.Text + "' , '" + TextBox7.Text + "' , '" + TextBox8.Text + "')";

This is assuming "Tel number" actually has embedded whitespace in the database schema. Otherwise it's a typo and you need to remove that space. I mention this as an alternative because UserName doesn't have a space, which suggests either an inconsistent schema definition or a typo in the C# code.

But typically when getting errors like this I'll trace the query or print out the end result that gets run, then copy/paste and run it directly from the database. Often it's easier to debug from there than simply going by the stack trace in C#.

pritaeas commented: Brackets... I should've known. +13
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

what is the best boook?

The one you have the easiest time understanding. All books will get you started. Some are better from an experts view, but may not be suitable for all beginners because everyone learns differently and understands different explanations of the same concept. It's actually more important that you get a book you can follow than getting the "best" book.

All of the ones you listed are good.

and what is the difference between C++ primer and c++ primer plus?

I think the question should be what's not different? And the answer would be that "C++ Primer" is in both names. Otherwise they're different books written by different authors. Both are suitable, of course, and cover the necessary material to learn C++.

why not the newer version(primer plus 6th edition?

That's a different book. The 5th edition is the most recent for "C++ Primer".

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yup, it works now, with .clear() :). Thanks!

As a side note, the reason for that is the status flags of a file stream object are independent of the file that it points to. So if you open a file successfully, read it to EOF, then close it, attempting to open another file and read from it using the same stream object wouldn't work because the eofbit would still be set for the object.

As another example, your specific problem is that the open() member function failed on an invalid file name. This sets the failbit, which remains set even when you try to open a valid file name.

Calling the clear() member function clears the status bits.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

C style strings are pointers to characters

Add "sometimes" in there any I'll agree with you. The definition of a string in C is a contiguous sequence of zero or more characters terminated by '\0'. That means you can represent a string with an array (note that arrays are not pointers), or with a pointer to the first character in a block of memory that matches the definition.

The reason I mention this is because it causes a lot of confusion, and I think it's imporant in this case to be pedantic.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is it possible to make drivers from scratch in assembly and how easy is it????

Yes, of course it's possible. How easy it is depends on what the driver does, but it's generally a safe assumption that any production quality driver written in assembly wouldn't be described as "easy". ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I was only asking you to wait till he comes up with his version first.

I wasn't intending to participate in this thread any longer unless directly addressed (even before your request). So no worries on that front. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Chat isn't really meant for all but the most trivial Q&A. Even in the current IRC channel (when it's active), most in-depth technical questions are directed to the forum.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Can I still give a c-style-string to .open()?

Of course. Support for std::string was added as an overload.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Well, you could probably go through the minutes of the committee meetings, but I think in this case the rationale is pretty obvious. It's closing an consistency hole in the standard library where there's not an overload for both C-style strings and C++ strings.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

@deceptikon: please allow him to make the changes himself this time...don't put up a snippet for him.

He's obviously putting in the effort, and a good example every now and again can be far more enlightening than umpteen posts explaining what changes should be made.

While I appreciate that you have his best interests in mind, the unwritten rule of not doing someone's work for them can be taken to unproductive extremes.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I needed some clarifications w.r.t making functions thread safe.

Can you be more specific?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Judicious use of variable scoping can take care of that. Note how in the following code I've moved variable definitions to the smallest scope possible. I also initialized time to 0, adjusted your variable names to be more consistent/conventional, removed unnecessaries and tightened things up a bit:

#include <fstream>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    ifstream inFile("test.txt"); 

    if (inFile) {
        string journeyName;

        while (getline(inFile, journeyName)) {
            if (journeyName.empty())
                continue; // Discard empty lines

            int nChanges = -1;

            if (!(inFile>> nChanges)) {
                cerr<<"Invalid file format\n";
                return EXIT_FAILURE;
            }

            double time = 0; // Get your ass in gear soldier!

            for (int i = 0; i <= nChanges; ++i) {
                double length, speed;

                if (!(inFile>> length >> speed)) {
                    cerr<<"Invalid file format\n";
                    return EXIT_FAILURE;
                }

                time += (length / speed * 60);
            }

            cout<<"Travel time for "<< journeyName <<": "<< time <<'\n'<<endl;
        }
    }
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

line 9: the typecast and & symbol are not necessary, just extra fluff that means nothing.

Actually, the typecast is necessary when using the address-of operator. Which brings up my next point.

int *arrayAddr = (int*)&array;

If you're forced to use a cast to make this work, it should tell you that something is wrong. While the address of &array may be the same as &array[0], the type is different. That's why you were forced to add a cast to make the line work. &array has a type of int(*)[3] and &array[0] has a type of int*; the two are not compatible and as such cannot be mixed and matched in an assignment.

If you take away the address-of operator, C gives you both the correct address and the correct type as syntactic sugar. Then you can omit the now redundant cast:

int *arrayAddr = array;

Or you can be explicit:

int *arrayAddr = &array[0];
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Are we going to get a new Christmas theme for the site?

Sounds like a hassle, both technically and in dealing with complaints from people who don't celebrate Christmas and are mad that we didn't come up with a skin just for them. ;)

So it's like good old theme - never to be changed?

Actually, it changes almost daily to keep up with SEO and usability demands. Most people just never notice because the majority of changes are small.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It means print either doesn't exist entirely or doesn't have a definition. Presumably it's a function, which means you probably declared it but didn't define it.

totalwar235 commented: that was the answer +2
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Obviously it would require changes to your design. If you're not willing to make those changes then yes, it's a dead end.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That's not a bad guess, but the assumption there is that SREC is its own type, so:

SREC grades[500];

No doubt you know how to declare simple integer variables:

int field;
int size;

Now the only problem is wrapping those three into a structure.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

but there are very heavy complexities when running each npc in it's own thread

Yes, that's why I recommended against it if possible and gave an alternative that runs sequentially in small steps.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Start easier. Can you define an array of 500 SREC objects?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is there a way around this?

Run each dude in its own thread of execution. Or write Wander() so that it handles steps rather than the whole random wandering that I assume it does. That way you can process one step for each NPC in sequence and it'll appear as if things are happening simultaneously.

Honestly, if you can avoid threads without bumping or exceeding the complexity of using threads, I'd suggest that you do so.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

what I'm wondering is if this OS will be compitable with Vista ultimate??

http://winsupersite.com/article/windows8/windows-8-tip-upgrade-windows-vista-144320

Regardless of what's available, the usual advice for moving up Windows versions is to perform a clean install. Upgrades have improved over the years, but a clean install limits risks to things like hardware compatibility instead of hardware plus whatever stuff was on the PC before.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I hope not be booted out for ignorance.

No worries, the vast majority of Daniweb consists of people trying to learn more. Ignorance isn't looked down on.

"There's no such thing as a stupid questioin."

That's not true in my experience, but we don't hold stupid questions against people here. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Usually at school, where we use turbo c++ (Horrible) the file could be seen in the folder where the cpp file is saved......

Visual C++ does the same by default. Try running a simpler test:

#include <fstream>

int main()
{
    std::ofstream out("fooby.txt");
}

On my system that program places fooby.txt here:

C:\Users\deceptikon\Documents\Visual Studio 2012\Projects\CppScratch\CppScratch\fooby.txt

That folder is where the source files are stored, and that behavior hasn't changed between Visual Studio 2010 and 2012. It's also where the project (but not solution) file is stored. But as long as the name is unique, you can do a system search to find it. Don't forget to look in hidden folders too. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Are you using multiple inheritance?

Off the top of my head I don't recall if the C++ standard requires the base and derived object address to be the same for single inheritance, but it simply cannot be for multiple inheritance. There's no way to organize the structure of the object to make that happen. If you're using single inheritance then my gut reaction is to say that the addresses are implementation-dependent and you can't depend on them being the same.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Are you talking about just displaying a picture any way that works, or actually rendering the picture using C++? The former is vastly simpler; you can just start the process of a picture viewer and pass in the location of the picture to open it. The latter is quite a bit harder and not recommended.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

@deceptikon, the rep you gave LastMitch didn't count I believe because we are in a non-technical forum category.

Community Center, where the discussions can be anything and points don't matter. ;) Yes, I'm aware that reputation points weren't applied, but that doesn't make the rep worthless.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Possible, but not directly. The two options are basically to convert the number to a string and index that, or write a function that separates the number arithmetically and returns the digit at the selected index.

Edit:

Just for giggles, here's a fun example. :)

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>

class CoolInt {
public:
    CoolInt(int value, int base = 10)
        : _value(value), _negative(value < 0)
    {
        if (value == 0)
            _digits.push_back(0);
        else {
            value = abs(value);

            while (value) {
                _digits.push_back(value % base);
                value /= base;
            }

            std::reverse(_digits.begin(), _digits.end());
        }
    }

    operator int() const { return _value; }
    int operator[](unsigned index) { return _digits.at(index); }

    bool negative() const { return _negative; }
    int size() const { return _digits.size(); }
private:
    std::vector<int> _digits;
    int _value;
    bool _negative;
};

int main()
{
    CoolInt x(12345);

    std::cout<<"x is "<< (x.negative() ? "negative" : "positive") <<'\n';

    for (int i = 0; i < x.size(); ++i)
        std::cout<< x[i] <<'\n';
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I thought there was a limit for the maximum times a member can up/down vote another member in the same day?

That's a negatory. But after this I'm inclined to look into adding flood control to voting.

Were all those downvotes on the same day?

About 200 were yesterday and the rest were today.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i dont understand ur point......

My point is that something is wrong, you know what line it's on, and I can't look over your shoulder to properly hold your hand while debugging.

nd what is the reason behind that index is out of range

That's the question you're trying to answer by debugging the exception. You've rejected all of the possibilities I've pointed out, so now it's up to you to debug the line, add breakpoints, add watches, hover over shit, and look for values that aren't what you expected.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

This is like pulling teeth. Does anything look funny when you look over the elements of that line in the debugger? The exception isn't random just to wake you up, it's caused by something not right. And since the exception mentions an index out of range, the problem is an index out of range or a null where one is assumed to never be present.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So there's something up with Cell[6]. Does your datagridview have 7 columns? Hop into the debugger and check the Cells collection, make sure that index 6 exists and has viable data in it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The bookmarks would get lost in the watch list (I currently have 3 pages of Watched articles).

They'd also get lost in the bookmark list if you have a lot. ;) Maybe I'm just the only one that turns off automatic watching as a matter of course and only uses the feature for transient stuff or very important threads I don't want to lose.

A collection of favorite posts doesn't sound like a bad idea, but I would like to hear Dani weigh in on it before I start thinking about implementation.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The bear will be in the import modules

Nah, they're all pretty universal as far as features go. C# (.NET rather, and probably Mono) support all of them in some form or another.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That's kind of an awkward design. Let's say you're hashing integers, you could do something like this (assuming the class works like I think it does):

HashTable<int> ht(-1);

It says that the hash table will use -1 as the "item not found" marker value. The idea is that the argument represents a suitable sentinel value for searched items that aren't in the table.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Does the article watch feature not suitably do everything you want? It doesn't bookmark specific posts, but finding the post in an article shouldn't be a problem for all but the ones with many pages.

You can also click on the time posted link (at the top left of each post, next to your avatar or user name) to get a permanent link that can be pasted into another post as a cross reference.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Sounds like a good time to learn a little Python. :) No offense, but even though the program is short, I'm not sure anyone will be willing to do the conversion for you. If you have specific questions like which libraries correspond to each other between languages or specific problems/errors you're seeing, that's fine.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Admittedly with 951 down voted posts, it appears he/she is doing something wrong

Note that the vast majority of those votes were made by a single person. When looking at votes, also look at the unique voters. If the number of votes is high and the number of voters is low, that means a small number of accounts were used to make the votes.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

At a glance it doesn't seem like the Python code uses anything that's terribly difficult in C#. What parts are you having trouble with? Do you know both Python and C#?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Have you read Beej's guide to socket programming?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The admins don't seem to really care.

I care that you had a hissy fit and I called you on it. I don't care that somebody told you they wouldn't do your project as that's not against the rules. Ignore it if you don't like it, report it if you think it breaks the rules.

But latley I have been getting people saying we are not doing the whole project for you... ?

By lately you seem to mean once, by one person, and looking at the thread in question it's more like you simply went full crazy for no reason. Let's keep things in perspective, shall we?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The reason yours won't compile is because two stars means a 2d array

I'd disagree there because it'll cause confusion when trying to assign a 2D array to a pointer to a pointer:

int a[2][3];
int **p = a; // Still won't work!

The problem is that the type of &array in the original snippet is int(*)[3]. This type is incompatible with int**.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

i think you can go to ios for developing application on i phone....and java/android for all leading smartphones...

iOS isn't a language, it's a platform. Objective-C is the language that Apple has blessed for iOS development. At one point "third party languages" were disallowed, but that stance has changed. However, that doesn't mean Objective-C still isn't recommended.

Likewise, Google blesses Java for the Android OS but doesn't restrict other languages aside from it being a bit of a chore relative to Java.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The virtual machine would have its own registers simulated to match the simulated platform. Nothing else would make sense given that the host could be running a number of virtual machines.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

That's by design. The button goes away to ensure that you don't click it again (and thus create a duplicate post) while the submit code is running.

Just be patient, it should finish in a few moments at most and then refresh to show your new post. Sometimes server load causes things to run more slowly than we'd like, but I haven't ever seen replies take more than about 5 seconds to finish.

If you're getting really long wait times, please let us know.