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

If all you want to share is a header file and *.cpp file then I wouldn't bother making a DLL because that is like killing a fly with a sludgehammer. Instead, just create a static library project and add those two files to it. Then in each of the application programs just link with that library.

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

I think you might be talking about an array of pointers to some objects, and the pointers are NULL if it does not contain valid pointer. Something like this:

class MyClass
{
   // blabla
};

// an array of 10 pointers to MyClass objects, 
// initialized to NULL pointers.
MyClass* array[10] = {NULL};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No you don't call it -- but you do have to write the implementing code for it, something similar to the way you write implementing code for the other class methods.

CAccount::CAccount()
{
    // initialize class variables here
}

>>I dont really understand because I put the constructor in both classes
I see CAccountList() constructor but not CAccount().

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

>>undefined reference to `cAccount::cAccount()'

That means you defined a constructor in the class but never coded the implementation function.

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

Oh so it's D3D10CreateDeviceAndSwapChain() that can not be foud, not initD3D() -- my mistake. But the same suggestions still apply. According to this microsoft link that function is in D3D10.dll (scroll down to the bottom of the page and it will tell you what library it's in.)

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

>>but what does that mean?

Search the tutorial that you are using for that function. Must be there somewhere. If not then you are using the wrong tutorial.

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

>>Also initD3D is a user defined functio
I assumed that was in a library. But if not then look at our own code for that function. google found this tutorial that contains that function

>>I tried dumpbin.exe d3d10.lib in the command and I get a huge list of ... things?

Surprise! redirect output to a file, load it with Notepad, and search for what you want.

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

In the same folder as the compiler there is a program named dumpbin.exe. ( use a command prompt do run that file. You might also first have to run vcvars32.bat to set paths) It will list all the public symbols in a library. Run it against the library to see if it contains initD3D function and if it does was it's name mangled the same way your compiler mangled it.

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

You still failed to declare those two arrays as I showed you. Also problems in Change() function. main() returns an int, not void.

int main()

{

    char str[20]= {0};
    char enc[20] = {0}; 
printf("enter a string...");

gets_s(str);
Change(str, enc);
printf("%s",enc);


}




void Change(char *source, char *dest)
{

char *s;
char *d;
int i;
d=dest;
s=source;


for (i=0;source[i];i++)  
{
if(RLE (dest, source[i])==0) 
{
*d=source[i]; 
*(++d)=(RLE(source, source[i]))+'0'; 
d++;
}
}
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem is that you did not clear out the destination buffer when you declared it

char str[20] = {0};
char enc[20] = {0};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Plants plant1();

When declaring an object do not include the (). Its just Plants plant1;

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

Put this at the beginning of main() to hide the window and include windows.h ShowWindow( GetConsoleWindow(), SW_HIDE);

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

Sorry but that is not a quine program (see this link).

A quine takes no input. Allowing input would permit the source code to be fed to the program via the keyboard, opening the source file of the program, and similar mechanisms.

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

The only thing about VC++ 2008 that I do not like (same with version 6.0) is those blasted docking windows. Every once in awhile I accidently undock a window and have a real hard time putting it back into position.

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

64-bit memory addressing enables applications to store large data sets entirely in memory. This eliminates the performance penalty associated with swapping portions of the data in and out to disk

Yea, that's great ... until the lights go out unexpectently :) But that wouldn't matter if the database is read-only anyway, or immediately saves changes to disk on updates.

Otherwise that was an excellent article.

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

The error is on line 13 of the main.cpp, not car.h. change it to this: std::string myMake="Porsche";

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

I'm using Windows 7 and I can't make GetOpenFileDlg() to work. Maybe its deprecated because Microsoft recommends using IFileOpenDialog now. But I'm certain that GetOpenFileDlg() is still support otherwise no program written before Vista would work on Vista or Win7.

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

<string> is where std::string class is declared. <string.h> declares C string handling functions such as strlen(), strcat() etc. It has nothing to do with std::string class.

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

Ignore the first warning about incremental linking -- I get that sometimes too and means nothing.

The second problem, just go to the bottom of the source code file and hit the Enter key so that there is a blank line at the bottom of the program.

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

Did you try thing: this->panel1->Visible = false;

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

Two main problems:
1) WriteOutput() is destroying the value of result_NameONE and result_NameTWO. Delete those two lines at the beginning of that function because they are set in the Search function.

2) SearchNames() -- the last two parameters must be passed by reference. That function is also much more complicated than it needs to be. Here's another way to do it

void FindName(string names[], int rTotal, string sname, int &count, bool& result)
{
    for(int i = 0; i < rTotal; i++)
    {
        if( names[i] == sname)
        {
            count = i;
            result = true;
            break;
        }
    }
}
void SearchNames(string names[], int &rTotal, string &rNameONE, string &rNameTWO, 
				 int &rCount_NameONE, int &rCount_NameTWO, bool& result_NameONE,
				 bool& result_NameTWO)
{
	/* This is the search function that implements a basic brut force
	   search to find the specified names that the user inputs. */
	rCount_NameONE = 0;
	rCount_NameTWO = 0;

	result_NameONE = false;
	result_NameTWO = false;
    FindName(names, rTotal, rNameONE, rCount_NameONE, result_NameONE);
    FindName(names, rTotal, rNameTWO, rCount_NameTWO, result_NameTWO);

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

Here is one way to do it.

And here is another method

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

just as you did with structure menber int ident you have to create an object of type NPC_det

struct NPC
{
	string name;
	int ident;
	struct NPC_det
	{
		int health;
		int attack;
		int def;
	} det;//end 2nd struct
}//end 1st struct
int main()
{
    NPC n;
    n.det.health = 1;
}
Suicidal_tool commented: Thanks for the quick reply! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This thread seems to be a good discussion of that topic.

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

How to put keys into the keyboard buffer depends on the operating system.

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

I would move line 18 down after line 20 so that the sum is only printed after you enter -999. That's where you calculate and print the average too.

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

Drop the course and take C++ Programming 101 course.

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

>>int sum(x);

That is just initializing a variable named sum to be the same as the value of variable x. That is not what you want. sum needs to be the total of all previous values plus the value of variable x. sum was already declared at the beginning of your program so you don't have to declare it again.

That line should be like this: sum = sum + x; , or another way of putting it sum += x; . Either way is correct, so you can choose either way of coding it.

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

Also, you don't need that x++; line -- just delete it.

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

thanks it worked. now i just needed to know how do i go about stopping the program if the user inputs -999 do i need and if else statement or can i change something in the loop that will make it stop if x=-999.

Look at that while statement -- when someone changes the value of x to -999 then the while statement will stop and program execution will jump to the next line after the end of the while loop.

secondly how do i create a function to calculate the sum, average, count, smallest and largest numbers entered?
thank you

Its not a function. Just keep track of the sum, count, smallest and largest numbers inside the loop, just after the cin >> x; line. The average is calculated after the loop finishes, which is average = (float)sum / count;

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

The folks at the NSA will pick your super secret password in less than a second. .

I doubt NSA will be interested in looking into my computer, so that's not any threat to me. If you have information that is super secret or sensitive then put it on an external hard drive and unplug it when not needed (which is what US military used to do when I was on active duty). If you are using a business computer then of course that is a more serious and different problem.

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

Don't know if there is a managed code to do it or not, but here is how to do it with normal win32 api functions.

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

>>while(x!=-999);
Remove the semicolon at the end of that line.

Next, when there are multiple statements in a loop the loop must be enclosed in { and } brackets

while(x!=-999)
{
   // blabla
}

Also, you will need to initialize all those variables to -0 so that they do not contain just random values. For example int sum = 0;

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

Get it as a string, then parse the string to find out what kind of data it contains.

[edit]Oops! Too late. Like ^^^ said.

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

Code below should at least partially solve the problem. There are several ways in which a UNICODE file can be encoded, and the first 2 to 4 bytes of the file will describe which kind of unicode encoding it is. Winipedia has a good article that describes all of them. The code below only implements the UTF-8 encoding, which is really just standard ascii characters. You will have to write the others if you want to implement them.

Unlike my previous attempt this version works ok then the file is opened in text mode.

Note that you will not see "Yes" printed on the screen because the file does not contain any blank lines.

As it turns out, the file you posted does contain the BOM but is otherwise just a normal ascii text file, which is the definition of UTF-8.

void ReadUTF8(FILE* fp)
{
    unsigned char iobuf[255] = {0};
    while( fgets((char*)iobuf, sizeof(iobuf), fp) )
    {
            size_t len = strlen((char *)iobuf);
            if(len > 1 &&  iobuf[len-1] == '\n')
                iobuf[len-1] = 0;
            len = strlen((char *)iobuf);
            printf("(%d) \"%s\"  ", len, iobuf);
            if( iobuf[0] == '\n' )
                printf("Yes\n");
            else
                printf("No\n");
    }
}

void ReadUTF16BE(FILE* fp)
{
}

void ReadUTF16LE(FILE* fp)
{
}

int main()
{
    FILE* fp = fopen("c:\\dvlp\\test_utf8.txt", "r");
    if( fp != NULL)
    {
        // see http://en.wikipedia.org/wiki/Byte-order_mark for explaination of the BOM
        // encoding
        unsigned char b[3] = {0};
        fread(b,1,2, fp);
        if( b[0] == 0xEF && b[1] == 0xBB)
        {
            fread(b,1,1,fp); // 0xBF …
Nick Evan commented: Excellent posts in this thread! +12
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No, but this will:

int (*function)() = &NewOpcodeInterpreter;

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

>>My reasoning is, I have to replace the relative jump with an absolute jump, to the address of my own function.

Bad idea. Why? Because the address in memory will change every time the program is loaded by the operating system. Therefore you will never know the address of your function in memory. And the byte offset to the beginning of a function in the *.exe file is not really relevant because it too will change when loaded into memory.

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

@freesif: Are you sure that file contains valid data? The file's contents are as shown in the attached. It shows each byte of the file.

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

>>CRectangle * d = new CRectangle[2];

That is just allocating an array of 2 CRectangle objects. It could have been written like then: CRectangle d[2]; . But if it did that then it could not replace the 2 with something else at runtime.

>>d -> set_values(5,6);
That is the same thing as d[0].set_values(5,6) only it uses -> operator. When using an array I prefer d[0].xxx instead of the pointer operator because it more clearly describes what that code is doing.

chaienbungbu commented: Thanks. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

hi thx for reply, but i will be grateful if you suggest corrections in my existing program !!!!

I did. My suggestion is to rewrite it. The code you posted is much more difficult than it needs to be. There's such a thing as over-thinking a problem.

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

More than likely that program (Form1.exe) is still running in the background. Do Ctrl+Alt+Del to get tack manager then look at the list of running applications. If Form1.exe is listed there then try to kill it. If not, then you may have to reboot your computer to get it out of memory. I get that problem too on rare occations because the program will die to to program bugs.

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

get all input first using fgets() instead of that loop. Then to remove trailing white space start at the end of the string, search backward for the first non-white-space character and truncate the string at that point.

If you also want to remove instances of two or more white space characters inside the string, then use a pointer to find the beginning of the sequence, another pointer to find the end of the sequence, then call strcpy() to shift everything left, overwriting the excess white-space characters.

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

My password contains the name of an artifact from one of my favorite TV shows plus some numbers. And I use the same password everwhere, including DaniWeb. I've been told that an ideal password that would be very difficult to crack would contain at least 8 characters, at least one UPPER CASE character, one lower-case character, two numbers, and two non-alphabetic or non-numeric characters (such as ~,.-+ etc)

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

>> Y we use DLL files?

Answer: Y not?

>>where we should use DLL files and where not
DLLs are never actually required -- the same thing could be accomplished by using statically-linked libraries. But then that would make the operating system and all the programs on it very very huge. You might not have a large enough disk drive to hold all that duplicate code.

One case is internationalizing programs. Instead of writing a whole program for each language (e.g. Entlish, Spanish, German, Chinese, etc) it can be done by writing language-specific resource DLLs. One program, many language-specific DLLs.

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

I was finally able to get it to work by opening the file in binary mode, not text mode. In binary mode the buffer will contain "\r\n" at the end of each string

#include <stdio.h>
#include <ctype.h>
#pragma warning(disable: 4996)

int main()
{
    FILE* fp = fopen("c:\\dvlp\\test.txt", "rb");
    if( fp != NULL)
    {
// The first two bytes of a unicode file contain -1 and -2 respectively, which is the unicode signature.
        char b[2] = {0};
        wchar_t iobuf[255] = {0};
        // read the unicode signature bytes
        fread(b,1,sizeof(b), fp);
        // read the rest of the file
        while( fgetws(iobuf, 255, fp) )
        {

            size_t len = wcslen(iobuf);
// Strip off trailing '\r\n' from the string
            if( len > 2 && iobuf[len-1] == L'\n' && iobuf[len-2] == '\r')
                iobuf[wcslen(iobuf)-2] = 0;
            len = wcslen(iobuf);
            printf("(%d) \"%S\"\  ", len, iobuf);
            if( iobuf[0] == L'\r' )
                printf("Yes\n");
            else
                printf("No\n");
        }
        fclose(fp);

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

the \ character is a special character in c/c++ and has to be escaped, meaning you need two of them remove ("c:\\users\\asus\\new.docx");

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

You need to turn off UNICODE. Go to menu Project --> Properties (last item in the menu), Configuration Properties --> General. Then change "Character Set" (3d from bottom on the right) to "Not Set".

Either that or use UNICODE string literals, such as _TEXT("Some string literal")

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

Read this article about how to pass strings between VB and c++

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

There is no such class or structure named wxNoteBook.