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

line 76: y = static_cast<int> (1 + rand() * (max / x));

If all you want to do is to generate a random number for the user to guess then why all that math? I'd change the function to just one line --return rand();

line 33: variable guessed is used before it has been initialized.

line 111: why is **guesses ** a parameter? It is never used in that function. If you want line 117 to change the value that is declared in main() then you need to pass the variable by reference, not by value.

int CalcNewMoney (int money, int bet, int* guesses)

You should not have two different variables with the same variable name -- it causes lots of confusion and bugs. I'd change the loop count to be standard i counter instead of guesses.

line 128: You will most likely get division by 0 errors because the value of guesses is 0 the first time through the loop.

Also the function can return without a return value (what happens after the loop finishes???)

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

delete line 26 because it destroyed the seed generated by line 25.

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

I would do it by using an array of 255 ints, each element in the array represents one of the characters in standard ascii character set. So, if you enter 'A', then all you have to do is increment array['A']++. When done, all the non-zero elements are what you want. Now, you know that many of the 255 elements will be unused, so you can limit the array to only 126 or fewer. If the array has 126 elements (values above 126 can not be entered on the standard English keyboard).

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

Cats only have 239. Ones in their body

You need to explain that one. I have no idea what that means.

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

You include .h header files, not DLLs. Header files are very simple -- the compiler's preprocessor adds those files to your program in the spot where you have the #include directive. link

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

I can drive my Prius 500+ miles between fillups, then then it's not 100% electric. It has a small gas engine to keep the battery charged.

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

Most likely the problem is compiler mangling names. c++ compilers change function names so that they can be overriden, while c compilers do not because c does not support overiding functions.

The most common way to prevent name mangling is like this

#ifdef __cplusplus
extern c {
#endif
#include "widget.h"
#include "ui_widget.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
#include "opencv/cvaux.h"
#ifdef __cplusplus
extern }
#endif

You should check your compiler to see if __cplucplus is defined when compiling c++ code. vc++ defines it but I don't know about other compilers.

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

Maybe, but I'll take my 52GPM Prius over your 23GPM car anytime. Granted, I have not driven it in the mountains or desert so that might make a difference. But around here the Prius has just as much power as any other standard car.

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

spintf() and many othere functions found in string.h expect strings to be null-terminated. That's how those functions know where the end-of-string is. Without that null terminator the functions will just keep looking through memory until it finds a byte whose value is 0, very possibly causing your program to crash.

I am using Visual Studio 2010.

then you should have no problem declaring an array such as unsigned char currentLine[20000]

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

am wondering why would one need to swapp the numbers in real life?

One very good reason is sorting numbers in either ascending or descending sequence.

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

Sometimes I count the number of commercials shown back-to-back -- The worst I've seen is 3 minutes of the show and 10 minutes commercials.

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

Mother Hubbard from Mother Goose was originally written in about 1590 and Mother Goose's Melody was first published sometime in the 1760s.

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

great :) so now your problem is solved??

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

you need to post the code that you tried, you should be able to declare arrays in excess of several thousand, depending on the compiler. If you are using old Turbo C then you may have run out of memory. It has limited memory and a very small stack.

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

Here you go, but don't be supprised if you get an F because your teacher will know at first sight you didn't write it

#include "stdafx.h"
#include <iostream>
#include <cliext/map>
using namespace System;
using namespace std;

void sort(int nums [], int numitems)
{
    for (int i = 0; i < numitems - 1; i++)
    {
        for (int j = i + 1; j < numitems; j++)
        {
            if (nums[i] > nums[j])
            {
                int tmp = nums[i];
                nums[i] = nums[j];
                nums[j] = tmp;
            }
        }
    }
}

int main(array<System::String ^> ^args)
{
    const int maxitems = 10;
    int nums[maxitems] = {4,5,15,4,15,2,9,11,14, 15 };
    sort(nums, maxitems);
    int sum = 0;
    for (int i = 0; i < maxitems; i++)
    {
        sum += nums[i];
    }
    cout << "mean = " << sum << '\n';
    int median = (nums[5] + nums[6]) / 2;
    cout << "median = " << median << '\n';
    cliext::map<int, int> freq;
    for (int i = 0; i < maxitems; i++)
    {
        freq[nums[i]]++;
    }
    int mode = 0;
    int n = 0;
    cliext::map<int, int>::iterator it = freq.begin();
    for (; it != freq.end(); it++)
    {
        if (n < it->second)
        {
            n = it->second;
            mode = it->first;
        }
    }
    cout << "mode = " << mode << '\n';
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I didn't realize that about the Prius -- I live in the mid-west where the temp is not nearly as hot as in Vagas.

Also check for conventions in town -- hotel/motel fees normally double at that time.

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

You could sleep in a motel or hotel, but at $200/day that would cost you $3600.00 USD. Campervans get terrible gas milage, gas costs about $3.60/gallon. Get a Toyota Prius which gets about 52 miles/gallon (I own one and is one of my favorite cars).

Next make sure you dress according to the time of year you visit. Los Vagas is in the dessert so it gets very hot in the summer. San Francisco is near the ocean so you might need a light jacket at night. If you are not a US citizen you will need to carry your passport and driver's license from whatever country you are from at all times.

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

Lines 1-4 are all incorrect. You can't declare character arrays like that and you can't use gets() like that. I think you need to pay more careful attention to how those are done. For example

char in[20];

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

look up strstr() function. Another way is to call strncmp()

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

Are the questions all in an array? If they are, just have a counter that points to the current question. Initialize it to 0 to indicate the first question. When the Next button is pressed, increment the counter, if it exceeds the number of questions then reset it to 0 so that it starts all over again. Same with Presious button but decrement the counter. It's a pretty simple solution to implement.

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

Is it possible that I could get it back?

Probably not -- you auto lose the badge when the period of your donation expires. For example if you donate $3 for one month and don't renew it the badge will only appear for the month of the donation. It's not permanent.

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

The difference is that eof() doesn't recognize end-of-file until an actual read is performed. When at end-of-file line 31 doesn't know it yet until line 33 is executed. But line 34 is executed whether at eof or not. That's a common mistake that new programmers do -- IMO eof() is almost a useless function.

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

not using .net

AFAIK WMI is .NET

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

line 5: how does that variable ever get reset back to 0 so that you can call the function again for a different string?

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

Have you read this article?

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

line 26: what happens when found+1 > str.length()? There is nothing in the loop to stop the loop at the end of the str. Replace lines 19-31 with this loop

found = str.find_first_of('a');
while( found != string::npos && (found+1) < str.length())
{
   str[found]='X';
   found = find_next_of(str, found + 1);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

c++ is completely object oriented programming language.

No it isn't.

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

Didn't you read this post to show how to backspace?

line 16: if Pass in line 15 is a pointer then you can't delete s1 on line 16 because it will invalidate Pass also.

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

There are two kinds of strings -- standard strings are char* which are 1 byte per character. This is normal in English language and a few other languages too. The other kind of strings are UNICODE strings, or wchar_t*, where each character is represented in two or more bytes. All languages, that I know of, can be represented in UNICODE characters.

Look at line 15 of the code you posted. LPCTSTR is a Microsoft typecast for const char*. Now in line 33 you declare a pointer of type TCHAR, which is another Microsoft macro (tchar.h) that can be either char* or wchar_t* depending on whether you compile the program for UNICODE or not. line 50 calls the function wcscpy() which is UNICODE only function that is the same as strcpy() but takes two wchar_t* parameters instead of two char* parameters.

In otherwids, you code is mixing two very different character types, char* and wchar_t*. Both client and server must speak the same language (use the same character representation). What I would do if I were you would be change OnClickedBsend() to use UNICODE strings just like OnReceive().

Here is a much more complete explanation

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

void* is just a generic term for a pointer of any type. For example, malloc() returns void*. If you really want a pointer of type char* then, in c++, you have to typecast the return value of malloc().

char* p = (char*)malloc(15);

In the above, malloc will allocate memory for 15 bytes of memory and return a pointer to that memory block. Since pointers are all the same size in c++ you can easily just typecast it to whatever kind of pointer you want.

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

what compiler? what operating system? what GUI library?

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

That's because g points to an entire class and you need a friend class that prints all of it. cout has no idea how to display the class.

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

ifstream and ofstream cannot be members of a class like you have them. It's probably better to just have inData() and outData() declare ifstream/ofstrem, open the file, then read/write.

void Billionaire::outData()
{
    ofstream outFile("filename.txt");
    //The output data is formatted accordingly
    outFile
        << setw(12) << "Name: " << getName() << endl
        << setw(17) << "Rank: " << getRank()
        << setw(12) << "Worth:" << left << setw(8) << getWorth() << right
        << setw(17) << "Age: " << getAge() << endl
        << setw(12) << "Source: " << getSource() << endl
        << setw(17) << "Country: " << getCountry() << endl << endl;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

remove the asterisk

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

iterators are pointers and need the -> operator not the dot operator

            cout << left << setw(0) << "--d" << diskQueue.size() << left << setw(4) << " "
                << left << setw(14) << g->getFilename() << left << setw(14) << g->getMemoryStart()
                << left << setw(14) << g->getFileLength() << g->getRW() << endl;
smitsky commented: Excellent help! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Remove const keyword after PCB::screen. const functions can't use the iterator.

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

Remove const keyword after PCB::screen.

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

My suggestion is to start by playing the game on a real board so that you see how it works.

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

According to this artcle origins of the word OK is unknown, but speculation suggests it came from the 1840 American presidential election.

The oldest written references result from its use as a slogan by the Democratic party during the American Presidential election of 1840. Their candidate, President Martin Van Buren, was nicknamed 'Old Kinderhook' (after his birthplace in New York State), and his supporters formed the 'OK Club'.

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

Why don't you just bind the DataGridView with the sql?

اشرف_1 commented: I do not understand +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 7: why are you repeating the same character 22 times in currentLine? Isn't once enough?

int j = 0;
while ((c = fgetc(file1)) != EOF) {
     currentLine[j++]= (char)c;
currentLine[j] = 0;

line 10: you need to NULL terminate currentLine before calling sprintf().

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

Looks like it is sending char* (line 15) and receiving wchar_t* (line 40)? Is that right? I don't think that will work. Suggest you change OnClickedBsend() to convert the string from char* to wchar_t* before sending it.

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

what is ID? what is rnd(ID)? Is that generating a random number seeded with ID? Or something else? What SQL database is this for?

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

// t-1 = second last and t-2 = secound first

What?? The second last is t-2, the second first is 1. Why do you need loops to find the second last and second first numbers?

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

what is not possible??

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

You really don't need that large if statement, just use the mod operator and replace lines 9-12 with just this one statement.

++counter[abs(input) % 200];

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

What compiler are you using? Try commenting out large sections of the code so that you can narrow down the location of the error.

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

If you wrote that code then you should know what command-line arguments it needs. Looks like it takes 11 integers on the command line.

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

No. array a is a one-dimensional array so a[i][j] won't work.

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

In lines 14-23 you need to count how many times each number appears in the array. For example if the array contains 1 2 3 1 2 3 1 4 5 there are three 1s, two 2s, two 3s, and one each 4 and 5. So the 1s win. There are several ways to do that, probably the simplest is to use a structure that contains the value in the array and the count of the number of times that value appears in the array. Another way to do it is to use two arrays instead of structure. Array1 contains the value that is in the original array and array2 is the count of the number of times the value in array1 appears in the original array

The two arrays will contain the following values

1  3
2  2
3  2
4  1
5  1

You will have to loop through the original array. For each element in the oritinal array
check if the value is already in Array1
if it is already in Array1 then increment the corresponding element in Array2
If it is NOT in Array1 then add it and set it's count in Array2 to 1.