nullptr 167 Occasional Poster

Because you are calling LookupAccountSidW(...), myDwordNameLength and myDwordDomLength will contain the buffer size needed in wide chars. Thus on lines 23 and 24 you are only allocating half the required size for each buffer.
Change those lines to:

myTrusteeName = (LPWSTR)GlobalAlloc(GMEM_FIXED, myDwordNameLength * sizeof(wchar_t));
myDomainName = (LPWSTR)GlobalAlloc(GMEM_FIXED, myDwordDomLength * sizeof(wchar_t));
BenWard commented: Saved my ass! +1
nullptr 167 Occasional Poster

AFAIK, the first call to LookupAccountSidW will return the buffer sizes needed in TCHARS. So you will need to allocate bufsize * sizeof(wchar_t)
You also need to free the memory.

nullptr 167 Occasional Poster

The executables created by Turbo C are totally incompatible with 64 bit operating systems.
On 64 bit Windows you should be able to run both 32 and 64 bit executables, you just need a non-prehistoric compiler to produce the executable.
Look into MinGW (GCC) and Visual Studio as already mentioned by Mike.

nullptr 167 Occasional Poster

It would appear that Ahmad is most adept at copy and paste.
Compare his last post to CrateMuncher's comment at http://www.reddit.com/r/answers/comments/2dplea/whats_the_difference_between_c_c_and_c/

Traevel commented: Good spot +6
Ahmad Imran commented: "Nice to meet u ", says CrateMuncher +0
nullptr 167 Occasional Poster

This looks like it was copy/pasted with some modifications from another coding site.
For the sake of consistency, you should always use CreateWindowEx and the WNDCLASSEX struct as CreateWindow and WNDCLASS are deprecated.
You also need to check function return values and handle any errors.
As for the main problems with this code:
You need to specify identifiers for each checkbox. At present they're both set to (HMENU) 1.
e.g

#define IDC_CHECKBOX1   200
#define IDC_CHECKBOX2   201

CheckDlgButton(hwnd1, 1, BST_CHECKED) needs to be sent to the HWND of your main window with the appropriate identifier. The same goes for BOOL checked = IsDlgButtonChecked(hwnd1, 1) which would be better if it was defined as
BOOL checked = (IsDlgButtonChecked(m_hwnd, IDC_CHECKBOX1) == BST_CHECKED);

Before you enter the message loop at line 37, there should be:

ShowWindow(m_hwnd, nCmdShow);
UpdateWindow(m_hwnd);

Where m_hwnd is the HWND returned from creating the main window.

m_hwnd = CreateWindowEx(...);
if (m_hwnd == NULL)
{
    // handle error and exit
}

If you are coding in C++ then use the appropriate C++ headers rather than the C headers. (Do a google search for cstdlib vs stdlib.h) and only include the headers that you will be using.

Have fun. :)

ddanbe commented: Deep knowledge +15
nullptr 167 Occasional Poster

Also in line 11:
count<<"enter second amount";
It should be
cout << "enter second amount";

L7Sqr commented: Nice catch :) +9
nullptr 167 Occasional Poster

Read the rules - https://www.daniweb.com/community/rules
You will not receive help at these forums for any illegal activities.

nullptr 167 Occasional Poster

You need to make an honest attempt to write the code for your homework, otherwise you'll receive no help.

nullptr 167 Occasional Poster

Remove #include <string.h> and replace with #include <string>
As the string object is in the std namespace, you can either replace all functions and variables in the Dog class that contain string to std::string
or
put using std::string; before the Dog class.

nullptr 167 Occasional Poster

Who cares what I prefer, isn't it about which design you prefer?
If I was to get a new Windows PC then I'd go for Win 8.1 simply because it's architecturally superior.

nullptr 167 Occasional Poster

That question has already been answered in your thread at MSDN.
For an idea about drawing non themed buttons refer to http://blog.quppa.net/2012/02/12/drawing-non-themed-push-buttons-in-windows/

cambalinho commented: thanks for all my friend +2
nullptr 167 Occasional Poster

The first computer I actively used was an Atari 1040ST, mainly to be able to run Steinberg Cubase.
http://en.wikipedia.org/wiki/Atari_ST

nullptr 167 Occasional Poster

Edit to above post.
Re 2. It works on Windows 7 without visual styles for buttons, I've not tested on other OS.
I know for things like menus it just ends up ugly and unaligned without visual styles.

nullptr 167 Occasional Poster
nullptr 167 Occasional Poster

Seeing as your data file contains white space between last and first names, you'd be better off using std::getline for the reading.

void read_names(string names[], ifstream& infile, int& index)
{
    index = 0;
    std::string str;

    while (std::getline(infile, str))
    {
        if (!str.empty())
            names[index++] = str;
    }
}

At line 68: if(names[j].compare(names[i])<0) should be
if (names[j].compare(names[smallpos]) < 0) //or (names[j] < names[smallpos])

The outer loop in selection_sort should be for (int i = 0; i < size-1; i++)
The inner loop for (int j = i + 1; j < size; j++)

Don't forget to close the infile once you've finished reading.

nullptr 167 Occasional Poster

Sample output = garbage given sample input.

It's poorly worded and formatted, but not garbage.
Look across all arrays.
At index 3, all arrays have a value of zero.
At index 4, not all arrays have a value of zero.
Therefore at index 3 the number of sequential zeroes is 1.
Similarly, at index 7 the number of sequential zeroes is 2.
At index 12, seq zeroes = 2

nullptr 167 Occasional Poster

In the hpp file you have:

#define ROW_LENGTH 4
int correctAnswer[ROW_LENGTH-1]; // correctAnswer[3]
int userSolution[ROW_LENGTH-1];  // userSolution[3]

Meaning that correctAnswer[3] is out of bounds for the array and therefore due to memory alignment has the same address as userSolution[0].

nullptr 167 Occasional Poster

Here's quite a simplistic example of a non high resolution timer that you should easily be able to incorporate in a class, extend its capabilities etc

#include <iostream>
#include <functional>
#include <thread>
#include <chrono>
#include <ctime>

void timer(int msecs, int reps, std::function<void()> callback_func)
{
    for (int i = 0 ; i < reps; ++i)
    {
        std::this_thread::sleep_for(std::chrono::milliseconds(msecs));
        std::thread thread_func(callback_func);
        thread_func.detach();
    }
}

void fire() 
{
    clock_t t = clock();
    std::cout << "fired: " << t << std::endl; 
}

int main()
{
    std::thread my_thread(timer, 3000, 5, fire); // trigger fire() every 3 seconds for 5 repetitions
    my_thread.join();
    std::cout << "\nWe're done!\npress Enter to exit...";

    std::cin.get();

    return 0;
}
nullptr 167 Occasional Poster

Post the code that you have, it saves us all from playing guessing games.

nullptr 167 Occasional Poster

At line 63 you have cout << CorpData;
You need to use an instance of CorpData, for example cout << West;

You'll also need to set the precision when you output the data seeing as it contains double precision values. If you add limits to your includes, then the function could be written as:

ostream &operator<<(ostream &lhs, const CorpData &rhs)
{
    lhs << std::setprecision(std::numeric_limits<double>::digits10 + 1)
        << rhs.Name << " "
        << rhs.firstQ << " "
        << rhs.secondQ << " "
        << rhs.thirdQ << " "
        << rhs.fourthQ << " ";

    return lhs;
}
Ancient Dragon commented: good :) +14
nullptr 167 Occasional Poster

This may be what you're after.

LPPAINTSTRUCT lpps = new PAINTSTRUCT;
HDC hdc = BeginPaint(hWnd, lpps);
SelectObject(hdc, GetStockObject(DC_BRUSH));
SetDCBrushColor(hdc, RGB(180, 0, 0));
Rectangle(hdc, lpps->rcPaint.left, lpps->rcPaint.top, lpps->rcPaint.right, lpps->rcPaint.bottom);
//
cambalinho commented: thanks for all +2
nullptr 167 Occasional Poster

Something like this?

hbrBackground = CreateSolidBrush(RGB(241, 245, 251));
//
case WM_PAINT:
{
    LPPAINTSTRUCT lpps = new PAINTSTRUCT;
    HDC hdc = BeginPaint(hWnd, lpps);
    FillRect(hdc, &lpps->rcPaint, hbrBackground);
    // other code
}
cambalinho commented: thanks +0
nullptr 167 Occasional Poster

Also, 5 is never counted because arr[5] is out of bounds.

sepp2k commented: Seems like I missed the point of the question. +6
nullptr 167 Occasional Poster

If all the drink names are comprised of two words, then it would be far easier to read the file as follows.

    int i = 0;
    string word1, word2;

    while (infile >> word1 >> word2 >> d[i].cost >> d[i].num)
    {
        d[i].name = word1 + " " + word2;
        i++;
    }

You'll also need to fix your payment function. The problem should be obvious once you've correctly read the file and tested.

nullptr 167 Occasional Poster
typedef char alphabet[26];

alphabet alpha = {
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 
        'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
};

What you could do is iterate through the text that you read in and use a rotate function on each character:

char rotate_char(char ch, int shift)
{
    if (!isalpha(ch))
        return ch;

    // (tolower(ch) - alpha[0]) gives the index into the array
    // modulus sizeof(alpha) ensures that the shifted index is in the array range

    return alpha[((tolower(ch) - alpha[0]) + shift) % sizeof(alpha)];
}
nullptr 167 Occasional Poster

line 18: int Main() should be int main() - note case sensitivity.
Also you never call your rollDice function, so you'll never know the roll count.
line 29: does nothing, seeing as you are not getting input for y from the console.

Can you work out how and where to call your rollDice function?

nullptr 167 Occasional Poster

One of my dogs had an ear infection and the odour was exactly as you've described. The only treatment was with antibiotics. These infections can cause a dog an awful lot of pain if left untreated, so I'd recommend taking him to the vet ASAP. Your nose and the dog will be grateful, though your wallet may feel a lot lighter.

nullptr 167 Occasional Poster

See if you can get a hold of the Windows 8 "Use now and serve me a subpoena later" edition.

nullptr 167 Occasional Poster

My contribution: The lady played the piano with broken legs.

nullptr 167 Occasional Poster

Are you calling SendInput like this:

    int screen_x = GetSystemMetrics( SM_CXVIRTUALSCREEN );
    int screen_y = GetSystemMetrics( SM_CYVIRTUALSCREEN );

    INPUT input = {0};
    input.type = INPUT_MOUSE;
    input.mi.dx = (x * 65535) / screen_x;
    input.mi.dy = (y * 65535) / screen_y;
    input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;

    UINT ret = SendInput( 1, &input, sizeof(INPUT) );
nullptr 167 Occasional Poster

Refer to this MSDN article.

nullptr 167 Occasional Poster

line 17: Should be double sum = 0;
line 28: You can't return 2 parameters

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

double average(int arrx[6], int *ptr);

int main(void){
    int arry[6]= {2, 5, 4, 5, 6, 7};
    int count = 0;
    double avg;

    avg = average(arry, &count);
    printf("The average is %.2f\n", avg);
    printf("The first number bigger than the average is %i", count);

    printf("\n\npress Enter to exit...");
    getchar();

    return 0;
}

double average(int arrx[6], int *ptr){
    int c = 0;
    double sum = 0;
    double a = 0;

    for(c = 0; c < 6 ; c++){
        sum = (double)sum + arrx[c];
    }
    a = sum/6;

    /* Set count to the first number greater than the average */
    for (c = 0; c < 6; c++){
        if(arrx[c] > a){
            *ptr = arrx[c];
            break;
        }
    }
    return a;
}
sing1006 commented: thx, you solve my problem by remind me can't return 2 parameters. +1
nullptr 167 Occasional Poster
double totalSq=0, avg =0;
total += num;
totalSq+= (num-avg)*(num-avg);

In the second loop:
Isn't the declaration of double totalSq=0, avg =0; only in scope for this loop? Shouldn't these values just be initialised before the loop and const removed from the initial declaration of avg - double avg = static_cast<double>(total) / count ;
How is avg in this loop mean't to be calculated? At present its value will always be 0.

nullptr 167 Occasional Poster

I'll attempt to explain this by showing each iteration of the while loop.
int x = 125

loop 1: count = 1, x = (125/10) which = 12
loop 2: count = 2, x = 12/10 which = 1
loop 3: count = 3, x = 1/10 which = 0
loop ends as x = 0.
So number of digits = 3.
Remember as mike pointed out that this is integer division.

nullptr 167 Occasional Poster

You just need to cast sum as type float.

float average (int sum, int size)
{
    return static_cast<float>(sum) / size;
}
nullptr 167 Occasional Poster
int Clip(int Val)
{
    return (Val < 0 ? 0 : (Val > 0xFF ? 0xFF : Val & 0xFF));
}

My simple contribution.

rubberman commented: Just what I was going to post! :-) +12
nullptr 167 Occasional Poster

Seeing as you're wanting to close the window, the main problem you're going to have is that with protected mode/IE7+ the first process created is a broker process that then then launches a low integrity process. This second process is the one you see, but the handle returned from ShellExecuteEx or CreateProcess is the handle to the broker process, which isn't of much use to you.

Using the com interface IWebBrowser2 would allow you to close the window:

#include <ExDisp.h>
#include <comutil.h>

#pragma comment (lib, "comsupp")

int wmain()
{
    if (SUCCEEDED(OleInitialize(nullptr)))
    {
        IWebBrowser2 *pBrowser = nullptr;

        CoCreateInstance(
            CLSID_InternetExplorer, 
            nullptr, 
            CLSCTX_LOCAL_SERVER, 
            IID_IWebBrowser2, 
            reinterpret_cast<void**>(&pBrowser)
            );

        if (pBrowser)
        {
            VARIANT vEmpty;
            VariantInit(&vEmpty);

            _bstr_t strURL = L"http://www.google.co.uk";

            HRESULT hr = pBrowser->Navigate(strURL, &vEmpty, &vEmpty, &vEmpty, &vEmpty);
            if (SUCCEEDED(hr))
            {
                pBrowser->put_Visible(VARIANT_TRUE);
                // wait 5 seconds
                Sleep(5000);               
            }

            // close window and clean up
            pBrowser->Quit();
            pBrowser->Release();
        }

        OleUninitialize();
    }

    return 0;
}
nullptr 167 Occasional Poster

Read the documentation on the SHELLEXECUTEINFO structure at http://msdn.microsoft.com/en-us/library/windows/desktop/bb759784(v=vs.85).aspx
In particular regarding the hProcess member.

nullptr 167 Occasional Poster
x=1;  
y=1;

if ( n > 0)
    x = x + 1; // this line will only be evaluated if (n > 0)

y = y - 1;    // this line will always be evaluated regardless of the value of n

Hopefully the comments I've included above will clarify things.

nullptr 167 Occasional Poster

line 44 should be int main() and obviously return an int value.

line 42 int total_scores(const int [][Cols], int)
line 58 int total_socres(const int array[][Cols], int Rows) notice the spelling mistake?

line 65 total = total + array [Rows][Cols]; - so for each iteration you are adding array[3][3] which is out of bounds for the array and would just contain memory junk.

It should be total = total + array[i][j]; which is equivalent to total += array[i][j];

As for getch(), using cin.get() would be preferable.
Better code formatting would be helpful both for you and others reading your code.

nullptr 167 Occasional Poster

In your original code you have: for (i = 0; i < n; i++) which increments i by 1 for each iteration.
The solution is to increment i by 2 for each iteration.
i += 2 // equivalent to i = i + 2

nullptr 167 Occasional Poster

line 9: You're trying to read everything into the same address space - &image_read[50][100]
Try changing it to - fscanf(myFile,"%d", &image_read[i][j]);

Ancient Dragon commented: Good Catch :P) +14
nullptr 167 Occasional Poster

You've got if (isalnum(word[i])), which basically means if word[i] is either a letter of the alphabet or numeric, you're failing it.
What you want to do is contained in Moschops reply. Check whether isalpha(word[i]) is false.
Also, when you get the new word on failure, you're not resetting i and you'd also want to use continue; after that so that you skip the i++ at line 12.

nullptr 167 Occasional Poster

Change lines 22 and 27 to match the function prototypes in lines 10 and 11.
You need to pass the correct variable name to each function.
e.g. displayArrayVal1( x_array);

The printf lines need fixing to something like:
printf("X-array1 = %u\n", x[0]);

nullptr 167 Occasional Poster

Personally, I find the wording of the question somewhat ambiguous. Hopefully this will help you.

#include <iostream>

using namespace std;

int main()
{
    int posCount = 0;
    int negCount = 0;
    int posSum = 0;
    int negSum = 0;
    int numb;

    cout << "Please enter any combination of ten positive\nor negative integers separated by whitespace, then press Enter:\n";
    for (int i = 0; i < 10; i++)
    {
        cin >> numb;
        if ( cin.fail() )
        {
            cin.clear();
            cin.ignore(90, '\n');
            --i;
            continue;
        }

        if ( numb > 0)
        {
            ++posCount;
            posSum += numb;
        }
        else
        {
            ++ negCount;
            negSum += numb;
        }
    }
    // simple input stream flush
    cin.ignore(90, '\n');

    cout << "\nThe sum of all positive integers = " << posSum << endl;
    cout << "The sum of all negative integers = " << negSum << endl;
    cout << "The sum of all integers = " << posSum + negSum << endl;
    // calculate the rest

    cout << "\n\npress Enter to exit...";
    cin.get();

    return 0;
}
nullptr 167 Occasional Poster

' ' is the space character which equals 0x20 or 32 in decimal.
The rest of the code is explained here > http://www.cplusplus.com/articles/1AUq5Di1/

Asmaa_2 commented: thanks alot for the link and your help :) +0
nullptr 167 Occasional Poster

Use std::getline(cin, deleteMovie);
At present, if you entered 'when i met your mother(2009)', only 'when' would be read into deleteMovie. The behaviour you see after that is because the input stream isn't empty. Refer to http://www.daniweb.com/software-development/cpp/threads/90228/flushing-the-input-stream

Also, remove the calls to main() from your switch cases. Never use recursive calls to the programs entry point as a way of looping.

nullptr 167 Occasional Poster

Use std::getline, at present when you have cin >> name, if the entered name is M John then only M will be read into the name, for information on why your program then terminates refer to http://www.daniweb.com/software-development/cpp/threads/90228/flushing-the-input-stream

nullptr 167 Occasional Poster

There's most likely some memory junk in the upper 16 bits of the ebx register,
so change mov bx,1 to mov ebx,1

jannesb1 commented: correct +0
nullptr 167 Occasional Poster

The simple reason for the error is that the scope in which BankAccount b1 is valid, ends with the closure of your if (input == "y") block.

Here's your code with a few minor alterations.

class BankAccount
{
    protected:
        double balance;

    public:
        BankAccount()
        {
            balance = 0.0;
        }

        BankAccount(double b)
        {
            balance = b;
        }

        void Deposit(double b)
        {
            balance += b;    
        }

        double getBalance()
        {
            return balance;
        }
};

int main()
{
    BankAccount b1; // default constructor called
    string input;
    double bal;

    cout <<"Do you want to create an account (y/n) ?"<<endl;
    cin >> input;

    if(input == "y")
    {
        cout <<"\nYour account has been created !"<<endl;
        cout <<"Specify your amount to deposit :"<<endl;
        cin >> bal;

        b1.Deposit(bal);
        cout << "Your initial balance is : "<< b1.getBalance() << "." << endl;
    }
    cin.ignore(90, '\n');
    getchar();

    return 0;
}

I'll leave it to you to handle the precision of the displayed double variables. What happens if I deposit or open an account with a negative amount of money? It's a good idea to validate any user input, so take that into consideration when you're coding.