Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you buy it yourself or get it as a gift? When you have to pay for it yourself then you'll be a little more careful.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Has to be vinalla ice cream, never tasted a bad brand of it. Baskin- Robins is good, but, like Starbucks, is overpriced.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

std::copy() does quite a bit of work before calling memmove(), so why not just call memmove() directly?

Also sure copy uses memmove() because C++ is build on C

That is only partially true -- C++ standards don't tell compiler writers how to implement c++ functions, just how the functions are supposed to work. std::copy() could have been implemented any number of different ways, such as using software loops. But on Intel-based systems memmove() is the most efficient way to do it because of the underlying assembly code instructions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I grew up, I didn't raised up.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

And all this time I thought beef was bred, not grown

How do you think baby cows get to be adults? Just like human children -- they are grown.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Beef is not grown in Canada?

Didn't know that, I thought the winters were too severe for them, but I've never been in Canada.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My compiler, vc++ 2012, produces errors when I compile your function that uses std::copy(). I changed it like this to remove the error

vector<int> exp(int *arr, int size){
    vector<int> temp(size*2);
    std::copy(arr, arr+size,temp.begin());
    return temp;
}

I used debugger to single-step through the code of std::copy(), and just as I suspected it eventually uses the standard C function memmove() to do the actual copy. Of course other compilers may implement std::copy() differently.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Which is identical to what I posted 21 hours ago :) Now you're just repeating what's already been said.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Alaska would be more similar to Canada then continental US because ground beef would probably be too expensive since it has to be shipped in. AFAIK beef is not grown in Alaska or Canada.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 17: That does not copy all the elements of one array into the other array, it is mearly an assignment operator that set the address of temp to be the same as arr and the memory allocated at line 16 is lost.

this produces an error

int *exp(int *arr, int size){
    int *temp=new int(size*2);
      temp = arr;
      for(int i = size; i < size*2; i++)
          temp[i] = i*2;  // <<<<<< Runtime error here
      return temp;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you cannot sell a "beef taco" if you cannot show that it actually contains beef

So what do they use up there in Canada?? The Tocco Bells around here use hamburger, which is ground beef. At least I don't think they use horsemeat or dogmeat.

I'm not a big fan of Tocco Bell, but I get some toccos maybe once every three or four months. I am a Big Mac fan.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can also do it without a loop by calling memcmp(), which compares two arrays byte-by-byte.

int a[] = {1,2,3,4,5};
int b[] = {1,2,3,4,5};

if( memcmp(a,b,sizeof(a)) == 0)
{
   printf("They are the same\n");
}
else
{
   printf("They are different\n");
}
Assembly Guy commented: Ahh the simple solution. Awesome +5
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The easiest way is to rearrange main() just a little by putting almost everything in another loop. Notice that the file is only opened once at the beginning of main() so that each scanf() will read the next word in the file. You need to add a check for EOF.

#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define S 25


main()
{
    //declare variables
    FILE *fp;
    fp = fopen ("words.txt", "r");
    for(;;)
    {
        int i;
        int x;
        char wtbg[S] = {'\0'};
        char gl[S] = {'\0'};
        char wip[S] = {'\0'};
        char guess = ' ';
        int numguess = 0;
        int numLetters = 0;
        int theSame = 0;
        int wresult = 0;

        //displays instructions for user
        Instructions();

        //get word from file
        fscanf(fp,"%s", wtbg);

        //copy length of wtbg to wip array
        numLetters = strlen(wtbg);

        DisplayArray(wtbg); 

        //printf("GUESS=%d", guess);

        //fill  wip
        for (i = 0;i < numLetters; i++)
        {
            wip[i] = '*';
            //printf("%c", wip[i]);
        }
        wip[i] = '\0';

        while (numguess != 6)
        {
            printf("GUESS THIS WORD:\n");
            DisplayArray(wip);
            guess = tolower(GuessLetter());
            gl[numguess] = (guess);
            printf("\nLetters guessed so far: ");
            DisplayArray(gl);
            wresult = CompareLetter(wtbg, guess, numLetters);
            printf("wresult=%d", wresult);
            updateWIP(wip, guess, wresult);
            //theSame = CompareArray(wtbg, wip, numLetters);
            //printf("\nAre they the same array? %d", theSame);
            //printf("NUM LETTERS = %d", numLetters);

            //update number of guesses
            //wresult = 0;
            numguess++;
            // ask if you want to guess another word goes here.
        }

        //printf("GUESS=%d", guess);}
    }
    return 0;

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 50: This is always reading the first word that's in the text file. You need to read a random word. After you've guessed the word correctly it's not much fun to use the same word every time you run the program.

Actually, now that I think about it you don't need to use a text file at all. Just get a word of random length and fill it with random letters. The word will be meaningless, but will always produce a random set of letters to choose.

lines 62-67: Initialzing wip is being done on every loop iteration, you don't want to do that. Move the while statement on lines 57 and 58 down to below line 67 so that wip is only initialized once before asking for user input.

line 84: You need to stop the loop when the user has entered the correct word, if the word is "one" then you don't want to keep on asking for letters after you've guessed the word. A simple check with strcmp() will solve that little problem.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

strncpy() is similar to strcpy(), both functions take two null-terminated character arrays as arguments. So neither of those functions will work in your situation.

Before calling updateWIP() array needs to contain the same number of characters as in the word that the user is trying to guess. So if the word is "hello" then array needs to be initialized with 5 spaces. If that is done your updateWIP() should work, assuming the value of result is one of the numbers 0, 1, 2, 3, and 4.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The loop on line 36 is wrong

int *expandArray(int arr [], int size) 
{

    int *newArray = new int [size * 2];
    int index;
    for (index = 0; index < size; ++index) 
        newArray[index] = arr[index];

//    for (int newElem = 10; newElem <(size*2); ++ newElem)
    while(index < (size*2))
        newArray[index++] = 0;

    return newArray;
} // end *expandArray

You can also get the same result by not using the loops at all.

int *expandArray(int arr [], int size) 
{

    int *newArray = new int [size * 2];
    memset(newArray,0,size*2*sizeof(int));
    memcpy(newArray,arr,size*sizeof(int));
    return newArray;
} // end *expandArray
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That's right -- drawing must be done in the same thread as the window or dialog box.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

could this be a defect of _beginthread?

No -- that's how Microsoft designed the api.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can't -- drawing must be done in the same thread as the dialog box. If you don't want the dialog box in the same thread as the parent then either put the entire dialog box in another thread or create a modeless dialog box.

Why Windows Threads Are Better Than POSIX Threads (e.g. CreateThread() better than _beginthread() )

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think it's just the normal Command Prompt window.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think what you want is a Windows Service Program

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm not saying it's impossible, but normally the parent will send a message to dialog so that dialog can update the text in the dialog's window. You can set up private messages to do that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you compile for debug then use it's debugger to single-step thorugh the program? How many elements are in the data array? Does the value of (j+i) exceed the number of elements in the array?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What compiler and operating system are you using? Have you checked the size of the arrays that the program is using to see if it's attempting to write outside the bounds of the array?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

parent window shouldn't be trying to draw on the dialog box -- let the dialog box do all the drawing.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Doesn't it know from the index?

what index?? I think the third parameter to the function is the number of characters in arrayb. not the index in arrayb that needs to be checked. Lets say the user enters the letter 'a', the letter 'a' is then appended to the other letters in arrayb. How's CompareLetter() supposed to know which letter in arrayb the user just entered?

Why not just pass the letter to CompareLetter() instead of the entire array of characters entered? For example:

int CompareLetter(char arraya[], char LetterToCheck)
{
    if( strchr(array1,LetterToCheck) != NULL)
       return 1;
    return -1;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think I'd rather just die a natural death now then wake up 1000 years from now, or be reincarnated with my current memory. Or be instantly transported to 1000 years from now Les Visiteurs comes to mind :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

setprecision() is in effect until you call the funcion to change the value for floats and doubles. Assuming rate is either float or double, on line 3 call setprecision(0) to not display any decimals. Then on line 4 you have to call setprecision(2) again.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Oh, now I understand. The arrayb is just a string of letters in any order. In that case you can use a function such as strchr() to see if a letter in arrayb is contained in arraya.

int CompareWord(char arraya[], char arrayb[], int size)
{
    int flag = 1; // assume all letters in arrayb are in arraya
    int i;
    for(i = 0; i < size; i++)
    {
       if( strchr(arraya,arrayb[i]) == NULL)
       {
           flag = -1;
           break;
       }
    }
    // now return the result
    return flag;
}

it can return the position of the correct letter to main so I can fill that letter into wip (words in progress) by replacing one of the astericks with that letter in

Then why are you passing the entire arrayb instead of a single letter? How is the function supposed to know which letter to compare? And if that's what you want it to do then use a different function name that better describes it's purpose.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Noah & the flood also never happened.

How do you know? Was you there? Probably a better translation would be that Noah's flood covered the world "as he knew it". It would have to rain for a lot longer than 40 days and 40 nights to actually flood the whold world as we know it today, and then it might have to empty all the oceans.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

CompareWord() returns on the first character. If the first character of each array are the same then CompareWord() returns i, which will always be 1, otherwise it always returns -1.

Is there only one word in each of the two arrays? e.g. not a sentence? If so, then you need to set a flag to indicate the two words are the same so that the function will compare all the characters in the word

int CompareWord(char arraya[], char arrayb[], int size)
{
   int flag = 1; // assume arrraya == arrayb
   int i;
   for(i = 0; i < size; i++)
   {
      if( arraya[i] != arrayb[i])
      {
         flag = 0; // not the same
         break; // exit the loop
       }
    }
    return (flag == 1) ? 1 : -1;
}

Or, an alternative way to do it is to just call strcmp(). Assumes both arrays are null-terminated strings and only contain one word.

  int CompareWord(char arraya[], char arrayb[], int size)
    {
       return (strcmp(arraya,arrayb) == 0) ? 1 : -1;
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The example code is MFC (Microsoft Foundation Class), which is VC++ c++ class. But the explanation about the mousewheel would apply to any compiler that uses win32 api functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Moon landing

I watchecd that on TV. Interesting, but not earth shattering.

Go to a harvest celebration by North American First Nations before the arrival of Europeans.

You wouldn't see much because there weren't any.

ride in a Viking longship

They'd probably slaughter you :)

Plus the conditions at the beginning of the universe were pretty unpleasent so you likely would not live to tell anyone about it.

Maybe, and maybe not. Maybe God said "Abracadabra!" and Poof! the universe was instantly created just as we see it today. And, BTW, that was only 10,000 years ago.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you read the article I posted? Or did you just dismiss it because it had too many words?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I would like to see the beginning of creation -- verify once and forall the existance of God. And verify how the universe was created.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is a good tutorial that explains exactly what you are looking for.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

One way to speculate what such a pill might do is to read about the life of Dr Who (BBC TV series). The first Doctor said he was just a kid when he left grade school at the age of 50. At another time, when asked what he was a Doctor of, he said he had a Ph.D. in everything.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I want to know how the species is doing 1000 years from now

Humans might be extinct by then and you might get eaten by a big bird of some sort.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I wouldn't want such a pill -- think about it, I wouldn't get Social Security for another 900 or so years!

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How is it less expensive to have no insurance?

The penalty tax is soo low that it's not worth getting the insurance for some people. Here are the rules.

  1. Year one: 1% of income or $95.00
  2. Year two: 2% of income or $325.00
  3. Year three and beyone: 2.5% of income or $695.00

Compare that with a $10,000+ policy.

how are you going to pay for the treatments with no insurance?

I agree with you that paying the penalty instead of buying insurance is a huge risk.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The public is being flooded with lies from Republicans

You mean the lie that people who like their present insurance won't have to change it???

So you first state that they are using SNAP to buy items that are not covered under SNAP

Seems like a conflict, but isn't. Suppose I have a bunch of tickets to get free food then trade them to someone for drugs. Or suppose I have a good friend who is a cashier and gets him to give me unauthorized stuff for those tickets.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is a cute video I just found about ACA.

I have to ask, if Obamacare is as bad as the Republicans say it is, why do they have to make up so many lies in order to discredit it? Surely the truth would suffice.

I think everyone is just scared of unknown future. It might just be less expensive not to get any insurance and pay the small penalty tax. The USSC said the penalty is a "tax".

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Why would anyone abuse SNAP

To buy booze, street drugs, and other things that are not covered under SNAP.

How would you being a WalMart cashier beable to tell if the people were abusing it or not

Because there is a list of items that people can get. If it's not on the list, then it can't be bought with SNAP (or WIC).

Even if this imaginary abuse is going o

Nothing "imaginary" about it.

Why is that a bad thing?

It's not a bad thing -- the bad thing is the abuse of the system, not that people can get free food.

And its not like SNAP is can be spend on drugs or jewlery or other unnecessary luxuries.

In theory, yes. In practice, maybe or maybe not.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Can you explain to me how Republicans

Nope, I'm not Republican, although I have voted Republican presidents just as I have voted for Democratic presidents.

defund SNAP

Yes, because it doesn't work due to too many people abusing the system, I've seen it with my own eyes when I was a recent WalMart cashier for 5 years.

keep millions of Americans from receiving affordable, basic health care

What makes you think they already receive health care? Just walk into any emergency room in USA and you will see people who have no health care insurance.

loosen gun laws so that even more people die

No one wants to do that. Republicans are agains gun control, not deregulation. I favor some regulation such as banning assult weapons not because such regulations will magically remove them from the hands of criminals but because it gives law enforcement ammunition to arrest people who have them.

AD - you are obviously opposed to the ACA.

I'm not opposed to the idea of ACA, from what I've heard it is just a bad law. One father said of TV just this morning that it will cost him at least another $500.00 per month. Insurance companies have cancelled the policies of several million Americans, leaving them with no insurance at all. I don't know how anyone can say that is an improvement.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The point of these requirements is to prevent wasting tax dollars

Like the $500.00 hammers? Or like reroofing a bunch of buildings one day and tearing them down the next day?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is an article about elipses. There must be at least one parameter before the elipses. For example:
void foo(int x, ...);

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You should use SetWindowLongPtr() so that it will be compatible with both 32 and 64 bit version of MS-Windows.

cambalinho commented: thanks +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

AFAIK there is none. Here is the list of valid styles. There are many other styles but they are specific to window type such as buttons, dialog boxes, check boxes, etc.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This article might be of interest to you. Codeproject.com has one of the largest repositories of free Windows code that you will find on the internet. You will find examples of almost anything you want to do there.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It restarts the device but the problem still persists.

Might be a hardware problem. Do you have another mouse you can try? Is it a USB mouse? Try plugging it into another USB port to see if it's a bad USB port.