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

you can start by deleting line 516 because it is nothing more than a huge memory leak.

When walking backwards you can't check for pCurrent == NULL because what you want to check for is while pCurrent != the head of the linked list, and the head is never NULL unless its an empty list. I assume pWalker is the point at which you want to start walking backwards, but what is the head of the linked list? If it isn't a gobal variable then you will have to pass it to the display function.

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

why do you need a whole tutorial just to declare an object with the extern keyboard? Its pretty trivel to code. Just put this near the top of the *.cpp file. extern int something;

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

Yes, you can do that. The problem is that you are doing double the work that is necessary, and its very easy to make mistakes in the extern statements between the different files. If you only have one or two variables/functions you want to declare extern then by all means just put the statement at the top of the *.cpp files that need them.

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

>>is it now better???
Don't ask me but ask yourself. Does it work right? No, then its not better.

lines 11 and 12: you need to initialize the arrays to 0. Easy to do like this: int value[5] = {0}; Now intialize the other one just like that.

line 23: should be testing value and array if(array[j]==value[i]) delete lines 27 and 29 because they serve no useful purpose.

There are at least a couple other problems.

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

You need to design some system to count the number of times each value appears in the array. If you do this with pencil & paper it will become clear how to do it. First start out with a clean sheet of paper, nothing on it. Now write column headings, one called Value and a little but to the right of that name it Count.

Now look at the first number in the array. Its a 1. Is there a 1 on that piece of paper? No because this is the first number, to under the Value column write a 1 and under the Count column write a 1 (first count).

Look at the second number. Its a 2, so is there a 2 under the Value column on the paper? No, so under the Value colum add another line with the Value of 2 and 1 in the Count colunm.

Look at the third number. Its another 2. There is alread a 2 under the Value column so increment is count from 1 to 2.

Do that for each of the other values in the array. After you are done you can easily see which Value has the greatest Count.

The above is the same concept you will use in your program. You could use two arrays of integers or one array of structures, whichever is easiest for you.

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

I would create a structure that contains a value and the count for that value

struct data
{
    int value;
    int frequency;
};

Now make an array of those structures and initialize everythig to 0. Then begin the loop you wrote on line 11. For each value in the array list search the array of structures for the value. If there isn't one in the structure array add one. If there is an element in the structure array for the value in the aray array then just increment the frequency counter. When the loop finishes you have the information you need.

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

>>while (stream1 >> aStudent.studentid)
when I compiled your code VC++ 2008 Express said aStudent is undefined.

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

you don't call ReadFile() to read the mapped file into memory. See the examples and explaination in this article. The whole purpose of memory mapped files is to share data between processes. When Process A writes to the share memory, such as using strcpy() function, Process B will be able to see it immediately as if it had done the strcpy() itself. You do not use file i/o to do this.

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

>>Would that do it?
That only tells the compiler where to find the libraries. It does not tell the compiler what libraries to use.

There are a couple ways to do it
1) add a #pragma comment(lib,"d3d9.lib") near the top of one of your *.cpp or *.c files. That forces the compiler to link with that library

2) Project --> Properties -->Configuration Properties --> Linker --> Input, then in the panel on the right add the library name in Additional Dependencies edit control.

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

how did you tell your compiler that it needs to link with d3d9.lib ? My guess is that you didn't.

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

post code. you probably need to pass the c_str() method from the std::string object, as I illustrated in my previous post.

CodeBoy101 commented: perfect! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>first !a is evaluated as the boolian result false, but then a boolian result can not be incremented.
Bingo!

>>(!a++) ie equel to (!(a++))
When in doubt, use parantheses for clarity.

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

>>i dont undestand how to do it

Ok, here's an example. Its not a complete program so you can't compile it as is.

string word;
ifstream in("infile.txt");
while( in >> word)
{
    if( word.length() == 3)
    {
           // this is a grade
    }
    else
    {
          // this is an ID
     }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1 001
002
003
2 005
009
004

If you look at the data you will see that the student id is just a single character, but grades are all 3 digits left-padded with 0s. So if you read the file in as words (strings) instead of integers you can easily test the string to see if the word is three characters then its a grade, otherwise its an ID.

read a word
is the length of the word 3 characters ?
yes, then we have a grade
no, we have a student id
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> I also tried including the C:\Program Files\Microsoft DirectX SDK (August 2007)\Lib\x64 and x86 directories (where d3dx9.lib is located),

Where did you add those paths? They should be in the "Library Files" tab, as shown in this thumbnail

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

>>When you install the August 2007 DirectX SDK, doesn't it make you put the files somewhere?
Only if you select "Save" from the download link., If you do then it doesn't matter where you save it.

If you look in the compiler's Options you should see this in the Include directory (see Post #2 above)
D:\Program Files\Microsoft DirectX SDK (August 2007)\Include

I installed the DirectX SDK some time ago and don't recall if the installed added that line to the compiler or if I added it manually. In any event check your compiler and add the location where you installed the DirectX SDK.

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

It doesn't matter where you save the downloaded file from the Dark GDK download link -- you don't even have to save it but just run it when prompted to run or save.

That will save a file names "Dark GDK - 161107.exe". You have to execute that program, which will decompress all the files and install them in "\Program Files\The Game Creators\Dark GDK". My guess is that you did not run that program. After that is done your compiler should be set up to go. Just open the example program located at "\Program Files\The Game Creators\Dark GDK\Samples\Visual Studio 9" and see if you can compile one of them ok.

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

Update: I just successfully compiled and ran the same program "Animation Showcase" without any problems at all. No compiler warnings or errors.

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

You probably need to follow the steps in these instructions for setting up the Windows SDK in VC++Epress 2005 - telling VC where to find the includes and libs and executables.

That's ok but he is not using that compiler. VC++ 2008 has all that fixed up. You don't have to do all that suff any more.

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

you will probably have to tell the compiler where you put all those files. Fire up the compiler, then select menu item Tools --> Options. Exand the Project and Solutions tab, then select VC++ Directories Change the list box Show Directories For in the right dialog box and add the paths in appropriate places.

I just finished installing Dark GDK, and the installation program added the paths in appropriate places as I described above. If yours didn't, then you did not install Dark GDK correctly.

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

>> Should't the order be the oppisite.
No -- the statement is evaluated from the inside out.

Here is another example of that

int bar()
{
    return 10;
}

int foo(int n)
{
    return n* 10;
}

int main()
{
   if( foo( bar() ) )
   {


   }
   return 0;
}

In the main() above, first bar() is called, then passes the return value from bar() to function foo(), after foo() is run the if part of that statement is evaluated with the return value of foo().

Always evaluate from innermost statement outwards.

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

maybe you mean if( !(++a) ) , which increments the value of a then checks if the value of a is 0.

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

>>Could you explain the two string arrays further

You can't use the original string array to insert the spaces for a couple reasons

  • the array may not be large enough to hold the additional characters.
  • the array may be a literal and stored in read-only memory, any attempt to change it would probably crash the program.

So to overcome those problems create another string array that is large enough to hold all the characters in the first plus the additional characters you want to add. Making the second array too large is ok, but too small can be a disaster waiting to happen.

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

that should be fairly simple. First find the comma and back up one character. That is where you insert the space. Add another space immediately after the command, and a line feed one character beyone that. Do it with two string arrays -- the first is the original string and the second is the altered string.

I would write it for you, but I don't want to spoil all your fun :)

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

Sorry about that, but yes, that is my problem.

If this is schoolwork then your teacher should tell you how to do it. Otherwise, its nearly impossible for a program to check a string and add spaces where necessary to make it understandable to a human reader. You need to get more information from whoever gave you the requirements for the program.

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

Need an example. you want to change "WethePeopleoftheUnitedStates" to this: "We the People of the United States" ? If the text is in a file then you will have to completly rewrite the file. First open the original file for reading, then another file for writing. In a loop read a line, modify it in memory as desired, then write the modified string to the output file.

Problem: how do you know where to add the spaces and new lines ?

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

Ok people -- stop arguing about something not relevant to the topic or helpful to the op.

>>that i can display it using outtextxy() ...is that possible
Yes -- as Salem and Duoas have already mentioned. Displaying the text from a file should not be difficult unless you want to do fancy things such as color coding, changing font sizes and paginating.

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

you misspelled the filename. d:\study material\SEN\MyWork\EvevtHandler.h

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

line 15. Wong check. You need to check argc to see if it is > 1. Then move lines 11 and 12 inside that if statement, between lines 15 and 16.

line 18: EOF is an integer, not a char. So you need to redefine variable c as int, otherwise if you leave it along that loop will never stop.

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

Here are some other possible causes for that error number. One of the reasons is that your project is set up to use precompiled headers and the file "stdafx.h" is not present in the project. Solution is to turn off precompiled headers.

What compiler are you using? Do you have windows.h on your computer ? If not then you will have to download the huge Windows SDK.

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

Is EventHandler.h is a file that you created? If it is then use Windows Explorer and check if the file exists ? Is it in the same folder as the other source files, such as try.cpp ? If all those are ok, then post the code for the file that gives you that error.

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

Of course its possible, but I don't remember how to do it because that compiler you are using is about 20 years old (maybe more) and is only used nowdays as a toy for kids to play around with. Anyone who really wants to learn how to program would use one or more of the many free modern compilers available today. Afterall, you can't learn to drive your dad's car by first riding a horse.

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

Lets say you want the file names to be
MultipleFileCopyModule1.exe
MultipleFileCopyModule2.exe
MultipleFileCopyModule3.exe

To accomplish that you have a couple options:
1:) call CopyFile three times

std::string filename = "C:\\Dev-Cpp\\Programs\\MultipleFileCopyModule";
CopyFile((std::string)(filename+".exe").c_str(),  (std::string)(filename+"1.exe").c_str(),false);

CopyFile((std::string)(filename+".exe").c_str(),  (std::string)(filename+"2.exe").c_str(),false);

CopyFile((std::string)(filename+".exe").c_str(),  (std::string)(filename+"3.exe").c_str(),false);

2) Use a loop if the number of names is unknown at compile time, something like this:

#include <sstream>
#include <string>
...
...
std::string filename = "C:\\Dev-Cpp\\Programs\\MultipleFileCopyModule";
for(int i = 0; i < n; i++)
{
     std::stringstream newname;
     // create a new filename
     newname << filename << i << ".exe";
    // copy the file
     CopyFile((std::string)(filename+".exe").c_str(), newname.str(), false);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why do you think CopyFile won't work for you? Its one of the easiest win32 api functions you can use.

for(i = 0; i < NumberFiles; i++)
{
    CopyFile(OriginalFilename, filename[i], FALSE);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

just write it multiple times using a different filename each time. Or write the first file then call os-specific command to make additional copies.

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

Except for the facts like C++ has more keywords, so int new; will not compile in C++, but it will work without any problem in C.

you have that backwards. the new operators is in c++ not C.

What's the difference between C and C++. Hundreds of differences. You can't take a C program and expect it to compile with a C++ compiler, and vice versa. Think of them as two completly different languages. As with most languages there are many similarities but there are also many differences.

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

post your code because I can't see your monitor very well from my house :) argc parameter tells the number of arguments on the command line plus one for the program name itself. In your example, argc should be 5, and the valid strings in argv are

argv[0] = program name
argv[ 1] = -bg
argv[ 2] = red
argv[3] = -fg
argv[4] = blue

If you attempt to read other strings in argv then your prog ram will most likely core dump.

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

!a returns a boolean value which can not be incremented.

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

>> cin>>"goldennumber";
remove the quotes. it should be like this: cin>>goldennumber;

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

you forgot to include <string>

>> system ("pause") ;
Don't do that. Just use cin.get()

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

Yes -- buy XP Server and the number of desired licenses.

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

If you work with Microsoft compilers and do any COM programming (such as for distributed processing and inter-language support) you will come across the VARIANT structure with is nothing more than a structure with two objects:

  • unsigned int type -- declares the type of data contained in the structure
  • union -- a uniion of a lot of different data objects, such as char, short, long, char*, etc

win32 api has several functions that work on the VARIANT structure, and there is a _variant_t c++ class that wraps the VARIANT and some functions.

As for your question, yes under some circumstances a function can return a VARIANT or _variant_t object.

#include <windows.h>
VARIANT foo()
{
    VARIANT vt;
    VariantInit(&vt);
    return vt;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

when compiling from a command prompt you need to set the PATH environment variable to include the compiler's bin directory or whereever the compiler's executable files are. you can do like this:
write a small batch file that contains this line SET PATH=%PATH%;C:\BORLAND\BCC55\BIN Then every time you create a command prompt you have to execute the above batch file. You can also just simply type it instead of writing a batch file, but a batch file saves time.

There is another way to make the change permanent, but how to do it depends on what version of Windows you are running.

>>void main
main ALWAYS returns int, so the only legal declaration of that function is int main() [edit]
>> I have also appended the path in the system variable with C:\borland\bcc55\bin
Oops. I didn't notice that statement when I wrote the above. Did you display the path to verify you did it correctly ? In older versions of Windows the path can become too long and attempts to add more stuff will fail.

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

what operating system ? what version assembly language? what assembler?

Essentually you have to open two files -- input file for input and result (output) file for output. In a loop, read a line from the input file, then write to the output file either the original file or the replacement. Finally close both files.

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

fork() only for *nix operating systems, MS-Windows doesn't support it.

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

suggestions:
1. move line 10 srand() up above the loop. It should only be called once within the lifetime of the program. most people call it like this: srand( time(0) ); 2. why do you need the array?

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

>>I`m telling you, you cannot read the content of .xls file.
It could be done but with great difficulty and probably very risky and for those reasons I wouldn't do it. The Microsoft Office SDK would be the best and safest solution but it too requires quite a bit of programming experience.

Salem commented: Not to mention giving MS a shed-load of money :) +15
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>It is really heavy to learn from MSDN for me
You're not alone, most programmers have that same feeling. That's why there are so many books on it. Just search amazon.com for win32 api books or read this thread. Yes books aren't cheap but if you are serious about programming then they are indespensible.

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

Only make the class abstract (meaning with pure virtual functions) if there is a reason to do that. Don't create a pure virtual function just for the sake of making it an abscract class. There are thousands of base classes that do not contain pure virtual functions.

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

>>I put these three NULL because i do not know what mean
Try looking it up in MSDN and it will tell you what each of them mean.