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

Years ago we used Microsoft VC++ 1.52C compiler. We had a similar problem and found that malloc() itself cause memory leaks every few hundred calls. We wrote our own malloc() function and the problem disappeared.

You might write a small test program to see if malloc() is doing something similar with your compiler and operating system.

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

I created a new project in VC++ 6.0, copied the code you posted and compiled. Then imported the *.dsw file into VC++ 2008 Express. It compiled there with no changes, warnings, or errors. So your problem must be someplace else. Here is my program

#include <vector>
#include <string>
#include <windows.h>
using namespace std;

struct MyStruct
{
	VARIANT m_vtValue;
	_FILETIME tm;
	std::string str1, str2, str3;

};


int main()
{
	double dValue[25] = {0}; 
	vector<MyStruct*> m_xMyStructItems;
	int c = 0;

	for(vector<MyStruct*>::iterator item = m_xMyStructItems.begin(); item != m_xMyStructItems.end(); ++item, ++c) 
	{

		// Format output string according to data type:
		switch ((*item)->m_vtValue.vt) {
			case VT_UI1:
				dValue[c] = (double)(*item)->m_vtValue.bVal;
				break;
//(... snipped rest of switch cases )
		}
	}

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

>> What's the problem here?
Nothing. Your program produced expected results for me. I used VC++ 2008 Express.

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

I have no idea what invoke does. Never heard of it.

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

nobody is going to be able to help you if you don't (or won't) post the code. Guess you will just have to learn how to use your compiler's debugger, if it has one.

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

I would add the ports you want to use in the hosts file, then your program can read the host file to find out what ports to use.

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

Of course you don't. Don't you know SQL language? If not, then get a good book and learn it.

SELECT  Projects.*
from Projects, Employees
where Projects.id = Employees.id
and Projects.name = Employees.name
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't think there is any one right answer. I try not to use pointers unless absolutely necessary because they can cause memory leeks and other problems.

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

If you use ODBC it won't matter what databases you use as long as the databases support ODBC, and nearly all of them do.

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

>>I don't want to use system tables query and things like that.

Things like what? If you use ODBC the result set will contain the table information for the columns returned. I'm sure you could also query the system tables for the info using ODBC. More information might be found in the DaniWeb Database board

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

You don't. One socket, one port. On the server side you can reserve a block of ports for use by the server's clients in the hosts file. The location of that file depends on the operating system. On my computer running Vista its located here:
D:\Windows\System32\drivers\etc

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

what libraries, compiler, and operating system are you using to do all that drawing? If you want the previous cross to disappear when you move the mouse you will have to redraw the cross in the same color as the canvas background. It doesn't disappear on its own.

[edit]Or, more likey what ^^^ he said [/edit]

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

Aritle about how to do that is here. and the comments at the bottom of the page.

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

how about
% set path = ($path;.)

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

Post code because I can't see your monitor from where I am sitting :)

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

>>I need solution to this immediately.
Ok, so why don't you write it. I am watching American Idol on tv and don't have time :)

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

#include <windows.h> If you don't have that header then you will either have to download the Windows Platform SDK, which is pretty large, or write your own loop using clock() function.

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

The first OpenFile() should be pretty easy. Use the new operator to allocate menory for an array of ifstream objects, open each of the files, then return the array.

The second function is a little more complicated. You will need a loop to read one line from each file in each loop iteration.

Would I write the program for you? I could, but I won't. You give it a try and post the code you have written, then ask questions about what you do not understand.

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

you need to use the Sleep() function in Windows or sleep() in *nbix. Note the capatilization of the letter S.

while(true)
{
     // display a random number
     Sleep(500); 
}

If you don't want to use that system functin then you could probably create a loop using the clock() function.

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

use srand() to seed the random number generator, rand() to get a random number, and the mod operator % to imit the number betwen 1 and 10. Get that working in your program first, then we can talk about how to make it do that every 1/2 second.

You can find examples lof those functions simply by searching this board or google for rand()

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

Here is an example of how to copy all the subfolders and files to a new destination folder. Looks like you are using managed code, so I don't know how to use unmanaged win32 functions in managed programs.

#include <windows.h>
#include <iostream>
using namespace std;

int main()
{
    SHFILEOPSTRUCT sf;
    memset(&sf,0,sizeof(sf));
    sf.hwnd = 0;
    sf.wFunc = FO_COPY;
    sf.pFrom = "d:\\masm32\\*.*";
    sf.pTo = "d:\\masm33";
    sf.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI;

    int n = SHFileOperation(&sf);
    if( n == 0)
    {
        cout << "Success\n";
    }
    else
    {
        cout << "Failed\n";
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

but that doesn't work when there is trailing white space. need to add a little code to trim trailing white space.

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

I'm using IE7 on Vista. Opening the image in a new tab doesn't help anything because the image is still unreadable. And clicking with middle wheel is the same as clicking with left button.

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

icode doesn't retain white space like code tags. Is it possible to make them consistent? Example:

// using icode tags "Now is the time " // using code tags

"Now       is     the       time         "
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you might have to add code to bypass all other white space (spaces and tabs) because I don't think strtok will do that. Example:

"No     is        the          time       "
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>anyone knows why?
Yes.

how about something like this:

char* lastWord = NULL;
while( tok != NULL )
{
   lastWord = tok;
   tok = strtok(NULL, " ");
}
printf("%s\n", lastWord);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Welcome to DaniWeb -- I'm just a few 5 years younger than you :) I think you and I are the oldest here, but there are a couple others pretty darned close. I hope you feel free to share your experiences and vast knowledge with everyone here on the technical boards.

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

Hi there,
Very ambitious individual aren't ya!
Welcome to the site, too.

Being from China I'll bet English is not his/her first language. So I think the word he wanted to use was devote, not sacrifice

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

Why the sudden interest in zip files? Some of us can't open them.

why not? If your computer is running *nix then the contents of the zip files may not be usable anyway.

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

Yes John I agree, but the OP clearly stated he is supposed to be learning c++, not C. Unless he is confused about what exactly it is that he is learning.

Moved to C board.

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

Hi,

I'm learning C++ programming and have to write a program that shows how to calculate tax rates for a business tha th as shops in 3 different cities with three different tax rates, using the printf function. Anyhelp I can get is appreciated. Keep in mind I am just learning programming for the 1st time. Thanks in advance.

That's rather odd -- c++ classes normally do not teach C functions such as printf(). All the code you posted is C, not C++.

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

it is a pointer Animal *x = *it; x->passTime();

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

They always look like that on my computer. Thought it was just me because I have the font size set pretty high on my computer.

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

Below is a small example of writing and reading in binary mode.
Note that the MyGame class does not contain a std::string but instead a fixed size char array for storing a string (str1).

The example I posted was wrong about that. binary write doesn't work with c++ objects like std::string

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

18 years ago I got this nice new job and I had to take over maintenance of a C program that was written by someone else long gone. The program was written for MS-DOS 3.1 operating system and had about 20 *.c files with lots of global variables scattered around all those files. Maintenance of those files quickly became a nightmare because of all those globals so I consolidated them all into one *.c file. Globals were used to help speed up the program -- function calls in a computer that only ran 10 Mz or so is very very expensive so globals was one way to improve performance.

If that same program were written today I would have strangled the original programmer and just trashed the program.

jephthah commented: "strangled the original programmer and just trashed the program" ... i dont know how many times ive had that exact thought. +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How to save the game depends on how the program is written. Since thre are over a gzillion ways to write a game its impossible for anyone here to tell you exactly how you do it. But lets say your program has two variables that need to be saved and later read back

class MyGame
{
private:
    int a;
    std::string b;
};

There are several different ways you could write it, but the quickest way is to write the whole class as binary data.

MyGame  game; // the game object
//

ofstream out("mygame.bin", ios::binary);
out.write((char *)&game, sizeof(MyGame));
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Welcome to DaniWeb. You can advertise your job needs in the Looking To Hire Forum

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

here its about 112.6p - 122.9p for unleaded and 124.2p - 136.0p for diesel

thats for 1 litre! (a litre is only about 0.2 imperial gallons!)

122.9 x 5 = 614.5

614.5p is about 12 and a bit dollars.

so yeah, your estimate is a true possibility for us in the UK

If I were you I'd walk, ride a bike, or ride public transportation. It is $3.85/gallen here today where I live. But it has always cost a lot more in europe than in US.

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

You cant have strcmpi(title eh? lol thinks how many will be laughing at me,lol well i think for a lassie i give it a good try,lol

I don't know what you mean by that. And its stricmp() on the compilers I use. But your compiler may have a different name because that function is non-standard.

But yes, you can use stricmp() or strcmpi(), whichever you want to use.

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

As for the other errors you mentioned just work through them one at a time. Fix an error then recompile to see new list of errors. Repeat until all errors are fixed.

Next time don't code so many lines without compiling and correcting your mistakes. Depending on the errors it might almost be more efficient to just start all over again and do it right this time. In the beginning you shouldn't write more than two or three lines of code before compiling. Even professional programmers don't write huge blocks of code without compiling and correcting errors.

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

>>char title[20][30];

30 characters is too small because a couple of the strings you are copying are longer than that. Might be better to use pointers, then you don't have to worry a about it, unless you intend to change the text of the titles

char *title[] = {
"Wind In The Willows",
"Fright Night",
"Women From Venus, Men are from Mars",
"Happy Days",
"Gone Fishing",
"My Sql",
"About Nothing",
"Beowulf",
"Shopoholic",
"Programming for Leraners",
"I love You",
"cardinal",
"The Birds",
"Three Men and Mice",
"Stig Of The Dump",
"Nowhere",
"Zulu",
"Deal with It",
"Klaxons",
"Learn to speak Spanish",
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Lord of the Rings was written by who? Blizzard possibly? Why don't you ask them?

Also, thanks for bumping a 2-year-old thread :)

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

do you mean the sort function beginning on line 84 ? Lines 97-100 look ok to me.

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

Sorry for this diversion, but I read the thread title and couldn't help but thik of Dr. Detroit movie :)

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

use the time() function if you only want accuracy to the second, of clock() for milliseconds.

const time_t MaxTime = 60*60; // one minute timer
time_t t1 = time(0); // start the timer
bool done = false;
while( !done )
{
    time_t t2 = time(0); // get current time
    if( (t2-t1) >= maxtime)
        done = true;
    // do some processing here
}

Or you could create another thread that does the timer stuff. When time is expired the timer thread tells the main thread to quit.

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

>>i use windows xp but i can migrate to ubuntu if u want me to use linux.
why would I care if you use *nix or Windows ?

Since you have the source code then change it to comment out all the file i/o stuff. Start by commenting out #include <fstream> . When you compile you might get a whole bunch of errors. Go through the error messages one at a time and comment out or delete the offending line(s).

That could amount to a huge chore, depending on the program. What are you going to do with the section(s) of the code that depend on the data that is read and/or written to the file system?

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

Then don't do that :) Don't put any code in the program that accesses the file system. Simple.

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

what is secondrow ?

while (std::getline(is, line)) 
{
    std::string::size_type start = line.find("+COPS:");
    if (start != std::string::npos)
    {
         write(lcd,secondrow,sizeof(secondrow));
         copsoutput = line.substr(start);
         write(lcd,copsoutput.c_str(), copsoutput.length());
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you should have deleted it as this is a request for pirated software which is a clear violation of the TOS as well as an incitement for peope to commit a crime (or help OP commit a crime which in itself is a crime in many places).

No its not. msdn can be downloaded for free from Microsoft. He just wants to know where to get the 2005 version instead of 2008 that is currently available at M$, or at least it used to be. I think all he wants is the help files which are also distributed free with some other compilers, such as Dev-C++.

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

>>cannot convert std::string to const void for argument 2 to ssize_t write(int, const void*, size_t)

the function write is wanting a pointer as the second parameter and you are passing std::string. The third parameter is also wrong. try this: write(lcd,copsoutput.c_str(), copsoutput.length());