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

It's actually pretty even -- 18 Republicans and 15 Demoncrats.

<M/> commented: ... you know what i mean -_- +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I've always seen 1M as one million, e.g. $1M is one million dollars.

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

The GUI will depend on operating system. Here's a tutorial for win32 api (MS-Windows).

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

worked for me using vs2013

 Enter values for x1 x2 y1 y2
1 2 3 4 5
 Distance from first point to origin :3.16228
 Distance from second point to origin :4.47214
 Distance between the two points:1.41421
Press any key to continue . . .
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

fn is a pointe to a function. It is set on line 11 but never actually used for anything. That is what your compiler is warning you about -- you could just delete line 11 with no loss.

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

unless you are sending a private message (one that you make up yourself) you can't control the value of lparam parameter. The easiest way to get a ponter to a specic instance of a class is to save the hwnd value in the class instance when it is first create, create a vector (or array) of class instances so that you can search the array for hwnd inside WinProc function. That's pretty much how Microsoft implemented MFC classes.

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

use your debugger and put a breakpoint on WM_CREATE. Since the window hasn't been created yet there can be no message box to show you.

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

All messages are sent to the WinProc() procedure -- the first parameter to that function tells you which hWnd the message is for. In the case of wm_create the message is sent before the window becomes visible.

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

Your program might compile but does the compiler produce any errors or warnings? You have to fix them befre you can run the program. I spot at least one error -- line 13, functions have to be declared before they can be called.

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

send it a text on your iphone?

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

Anyone knows how to do solve this problem.

Yes, don't you? Please post your attempts (code) to solve it.

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

That's not C code -- looks more like pascal or java.'

At any rate, in C/C++ you have to declare variables before they can be used. so if you want to use a vector then you have to incude the vecor heade file

 #include <vector>
 using std::vector;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Are you trying to wite a program with Notepad then compile it with VS iDE? The easiest was is not to use Notepad, but to do all your work is VS iDE. Here are a few articles to get you strted.

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

cin >> buffer will auto stop getting keys from the keybord when cin counters the first white apace (space, tab or '\n'). Buffer will never contain any of those white space characters, so your loop on line 13 ill never find one.

If you want buffer to include all white spaces too, then call getline() instead of sin.

cin.getlne(buffer, sizeof(buffer)); But here too buffer will not contain the '\n' characters.

strlen(buffer) will return the length of the string in buffer.

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

When you are a kid, all teachers are like Einstein :)

Reverend Jim commented: Some are like Frank-einstein. +0
<M/> commented: Actually, most kids won't know Einstein +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The way I understand it, __inline__is an older version of the inline keyword -- it was an extension to some compilers. It's pretty much obolete nowdays except for older c89 compilers (link).

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

It's really not all that difficult - the standard inline keyword is SUGGESTION to the compiler to duplicate the function contents each time it appears in the program -- the compiler can coose to ignore inline if it wants to. The gcc extension _always_inline causes thee gcc to duplicate the function all the time, whether optimizing the program or not.

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

might be gcc extension

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

Is this what you mean?

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

LPCWSTR is a ponter to a wchar_t* string. typecasting like you do on line 18 doesn't work. You have two choices: (1) turn off UNICODE strings and use just standard ascii strings or (2)
CreateFolder(L"E:\\DATA");

Note that the L in front of the string literal makes it a wchar_t* instead of char*

There are other choices and conversion functions, but you need to study about UNICODE strings.

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

maybe something like this: Replacing the * with your own criteria

IF EXITS(select \* from tablename where <clause>)
THEN
   ' increment counter
ELSE
   ' insert new row
END IF
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what language? In C and C++ (probably otheers too) you can call win32 api functions to get a handle to another application. But if start App B by calling CreateProcess() then it will give you the necessary handle.

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

read the questions here about C programming to get good ideas. You might just learn something new you didn't know before.

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

getch() is not part of the C standard. Use getchar(); instead.

Why use either one? cin.get() is already in <iostream> so use it instead of adding more C-code to the program.

.

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

lines 30 and 38: result() is not a function that has been previously declared.

line 62; Functions can only return one variable, not two.

It seems you have misunderstood the assignment. incr10() has two parameters passed by reference, not by value. Do not use the * when passing by value.

int incr10(int numa,int numb)

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

line 24 is all wrong. the insert command does not include the sql connection stuff. Please read the tutorial I posted earlier.

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

Yes, you are right -- line 2 jut prints a literal string.

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

think how you would do it with pencil and paper. You start out wit $1,000 then simply subtract the amunt of purchses.

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

Then you need to post exact code. The code you posted is wothless.

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

Looks like you are attempting to create a connection, nsert some data, and select somore other data all in one statement. Can't do that. You need to std a tutorial that teaches you the correct method of doing those things. Here is a very good one to get you started (see Chapter 13)

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

There are a number of ways that a valid Windows license may become invalid. One way is to install a new motherboard in the computer or make other significant hardware changes. I've had that happen to me a couple times. The telephone numberf Ummn referred to is in the error message on the screen and may change from country-to-country.

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

line 2: what do you expect prinitf() will display? first is just an ininitiaolized array of random caracters which may or may not contain '\0' which printf() looks for to find the end of the array.

line 4: what will happen if I enter more than 15 characters on line 3? Answer: the program will crash because memcpy will copy the last few characters outside the bounds of the array.

line 5: too few parameters to printf().

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

Jim, why are you so obsessed with American gun problems when you dont even live here? I don't see anyone making any posts posts about Canadian prolems.

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

tutorial here. You are expected to already know fundamtals of c++ language.

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

Your first task will be to learn the Sequential Query Lanaguage (sql). That is the language all SQL-compliant database servers use. There are many free tutorial online, such as these. Most, if not all, modern programming languages support SQL so it doesn't really matter which language you use.

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

everyone ask me to do this in C++ using getline(),

fgets() is the C equivalent of c++ getline() (almost anyway).

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

I assumed you were talking about printing a report to a lazer printer. If not, then please ignore my silly question.

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

do all clients have the same printers? Do you have the same printer as the clients?

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

what operating system is the computer running? I used to have lots of corrupt files with all versions of MS-Windows XP and older -- have not had such problems with Windows 7 and 8.

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

Of course I can not speak for Ms Dani, but as I recall her comments on this topic in the past is that she has no intent to restrict what the authors can do with the code they post, such as use it in work or schoolwork projects, it's just that DaniWeb owns the rights to the discussions about the code.

As for deleting posts -- it's DaniWeb policy not to delete a post/thread unless it violates one or more Rules. One reason for that is to avoid disrupting the continuity of the discussion in the thread. The poster can always ask a moderator to modify the contents of a post and remove personal information, such as real names. It is the poster's responsibility to ensure a post does not violate the policy of others, such as schools and companies the poster works for. If you post something that violated school or company rules, that's the poster's problem not DaniWeb's. DaniWeb is not responsible for such actions and will normally not delete a thread/post because of it. In a nutshell, it's the poster' problem, not DaniWeb's.

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

IMO the best solution is to not use std::string at all in MyClass but use a character array, which will ensure the string is written/read from the binary file without a problem.

class MyClass
{
   char str[126];
   // other objects
};

This solution is for writing data to new files, not for reading your existing data.

Jsplinter commented: Yes, thank you. That is what I will do in the future! +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why not just practice on your own computer?

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

That's because "%x" is an unsigned hex 32-bit integer on 32-bit compilers. See this article.

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

I havn't tried hacking 8, but I have tried hacking a horridly adware infected 7...

let's just say, XP is easier, broader, and less controlling than 7.

And that is exactly what Microsoft wants -- to keep you hackers out of their operating system. That's a bit Plus in my opinion.

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

I've always liked this Scribble tutorial

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

have you tried goodle?

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

Posts contributed to the community immediately become the property of DaniWeb upon submission.

See this link

ddanbe commented: Thanks for the info AD +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 11. sizeof a pointer always returns 4 on 32-bit compilers. There is no way for the compiler to determine the length of the data to which the pointer addresses.

Also about that same line and line 18. line 18 creates a pointer to a 1-byte string, yet on line 11 you are attempting to copy more than 1 byte to that memory. This is guaranteed to crash the program.

How do I fix it?

        int EncryptData(char *data_source, char *data_cipher, size_t sizeofdata)
        {
            char *tmp_data;
            long long int digit;
            tmp_data = new char[sizeofdata];

            /*
                Do some calculations here with some data and then store it in tmp_data.
            */

            memcpy(data_cipher, tmp_data, sizeofdata);
            delete[] tmp_data;
        }

// char* dest
int main()
{
    char dest[255] = {0};
    encryption.EncryptData("Hello world", dest, strlen("Hello world")+1);

        for(int i = 0; i < strlen(dest); i++)
        std::cout << dest[i];
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

enroll in a tech school that teaches such things.

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

Well, if your program is anything like the one below then the strings may not be anywhere in the file because std::string contains a pointer to where the string is located in memory, and writing out the class does not auto write out those strings. In this case you just lost all three weeks of work without any hope of recovery. Load the file into memory with a hex editor to verify whethere the actual text of the strings are in the file.

Also, run the program and you will see that sizeof(MyClass) is the same for all records in the file regardless of the length of the string.

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

using namespace std;

class MyClass
{
    int a, b, c;
    string s1;
    float d, e, f;
public:
    MyClass()
    {
        a = b = c = 0;
        d = e = f = 0.F;
    }
    void setstr(string s)
    {
        s1 = s;
    }


};


int main()
{
    MyClass c;
    string s;
    ofstream out("text.dat", ios::binary);
    for (int i = 0; i < 5; i++)
    {
        cout << "Enter string # " << i << '\n';
        getline(cin, s);
        c.setstr(s);
        cout << "sizeof(c) = " << sizeof(c) << '\n';
        out.write((char*) &c, sizeof(c));
    }

}

It is usually much easier to serialize c++ classes if you use char arrays instead of std::sting. This makes sizeof(MyClass) the same regardless of the length of the actual string within the array.

Jsplinter commented: Very clear example and excellent advice! +2