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

try this out

class MyClass
{
public:
	MyClass(int& xx) : x(xx){};

private:
	int& x;
};

int main()
{
	int x;
	MyClass  c(x);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Many of the now-old rich farts actually inhereted their wealth from their parents. The Rockefellers and Hiltons are just two of many such examples. On the otherhand, the richest man in the world (or was anyway) Bill Gates earned every cent of his money, but he certainly isn't "old" (except to a teenyopper).

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

I think you want to declare testString as static. That way every instance of the class will reference the same instance of testString.

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

McInsain didn't earn his money -- he married it. And do did John Kerry for that matter.

BTW: Only 64 days left until election day. I might just vote for McInsain because of his female vp, who will probably have to serve out most of his 4-year term.

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

I live in Illinois. Go to google maps. You will find Arizona near the bottom left of USA, next to California on the west (left) and Mexico on the south. Illinois (abbreviated IL on the map) is more towards the center of the map, both horizontally and vertically. Illinois is about 1,500 miles from Arizona.

>>don't you know Argentina?
what part of Texas, USA is that in? (LOL that's supposed to be a tired old Texas joke).

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

By the way, where are you from?

See the line just above my post count. If you are not familar with USA geography, then get a map and look near the center of the nation.

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

The moderators are alive and well. The OPs post was just too damed funny to warrent deletion. I wanted everyone to share in his humor. Sounds like it might be a good start to a winning game.

jasimp commented: Good point +8
Rashakil Fol commented: yase :) +9
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>P.S: Excuse me if my english is not well written! i'm doing my best! heheh
You did great :)

why don't you use the standard C function strlen() instead of your function Long()?

Since this is a c++ program why don't you use std::string instead of those char arrays?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
int** array = 0;
// allocate first dimension
array = new int*[10]; // array of 10 pointers
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The information is in the registry Example here

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

One solution: replace int store[10]; with either std::vector or std::valarray. With these you can store seemingly infinite amuont of numbers (of course it isn't really infinite, but close enough for most practical purposes).

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

>>Can someone help me on maybe how to start ?
Depends. Are you comfortable with writing c++ programs? If no, then start by learning the language.

If you know how to write c++ programs, then what is your knowledge of socket program? None, then google for socket program tutorials.

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

Yes, we can help, but not without knowing the details of the text file. Exactly what is in the file and how is it formatted. Post an example of the file.

Once you know that, all you have to do it open the file with ifstream object then read sequentially until you find the record you want. Can't tell you much more without knowing the details of the file.

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

Never mind I completely had an epiphany and got it done.

Good for you!

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

Start by understanding the mathametics of the triangle -- see this wiki article. That article gives you the solution for the 16 primitive Pythagorean triples with c ≤ 100. That should give you the data you need to verify the accuracy of your program.

One way to do it would be the long way, create two loops that count from 1 to 500. Inside the inner-most loop calculate the equation c^2 = a^2 + b^2. (where ^ means squared).

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

instead of using i+=step....U should use i-=step

I'm afraid not -- once the program is compiled the += operator can't be changed to -=.

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

you can't change the < operator to >, but you can change i to be greater than End and Step to negative, which I believe will accomplish the same thing.

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

By "string" do you mean std::string or a character array?

Character array: char *str = new char[1234]; Just replace 1234 with the desired length, which can be a variable.

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

cikara21: Huh? Is that supposed to mean something?

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

After the cin statement if a < b then just swap them so that you don't have to code for that condition.

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

>> could i have just passed &dims?
Yes. Don't dynamically allocate things unless you absolutely have to.

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

CRect is only 4 integers, so why bother allocating it at all. Just declare it without allocation and save yourself the bother of finding memory leeks.

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

Zip is about as primitive as it gets.

Agree -- that's what I used about 15 years ago. Zipped everything up and copied to floppy diskette. The problem is that zip files sometimes get corrupt and I lost everything. So I started just copying the files unzipped to diskette.

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

The functions declared in windows.h can be used in all languges. windows.h is specific to C and C++. The other languages have a similar header file that is targeted to that language, but they all reference the same win32 api functions.

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

It just means you can use C language to build gui MS-Windows programs. You can also use other languages, such as C#, VB, php, C++, and others. The win32 api functions were made by Microsoft to be called by as many different programming languages as possible. windows.h is just a header file used within C and C++ language.

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

I already told you how to do it in my first response to this thread. What don't you know how to do -- create an event handler in MFC or use the system() function?

And, BTW: please learn how to spell button

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

The easiest way is to create a new C++ MFC program. If you don't know how to do that then see Microsoft's Scribble tutorial. Too complicated to explain fully here.

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

what is "this botton" mean? Are you talking about a "button", such as something you click with the mouse? If yes, then call the dos program in the button's onClick event handler.

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

all you need is the HWND -- see RedrawWindow()

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

Depends on what you mean by "call my program". If you just want to launch the already compiled *.exe program then the answer is Yes. There are several ways to spawn an executable program. system() is one such function, win32 api CreateProcess() is another.

Why do you want to use VC++ 6.0 compiler? Is old and does not support c++ language very well. Get the free VC++ 2008 Express which is a pretty good compiler (IMO). Or you can get free C# Express which has gui programming built into the IDE. There are many alternatives, VC++ 6.0 should not be considered.

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

Its defining a pointer to a specific address. Works ok (probably) in MS-DOS version 6.X and earlier where that type of syntax was sometimes used, but it will fail in any modern 32-bit operating system such as MS-Windows and *nix. So if you are using a modern compiler then those defines because they won't compile.

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

wierd

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

see SetTimer(). With SetTimer() you can have windows call a function of your choicel at set time intervals.

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

>>Because of this thread is not closed yet
We don't close threads unless we have to normally when someone starts behaving badly or flaming starts.

Please post the whole program so we can run it and compare execution times with different computers.

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

>> while(!datein.eof())
That is a problem because it will read the last line of the file twice. Here is how it should be coded while( datein >> year ) [edit]After changing the above while statement I don't get your problem[/edit]

Easter is on April 4 1999
Easter is on March 26 1989

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

That error message mesans undefined external -- you forgot to code something. The error message should also have told you what the linker was looking for.

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

But back to the topic, how come vectors are equally fast as C-arrays in this example? That makes no sense at all. I thought ArkM showed they were at least factor 5 slower?

Unless I missed something he wasn't commenting on C arrays, but std::valarray versus std::vectors. There is little doubt that C array access is fastest.

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

I'll bet you put line 5 in the header file. Don't. put it in only ONE *.cpp file.

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

I've had enough of it because every little thing that happens I loose the sound. So tonight I got rid of it and went back to XP Pro. Glad I had duel booted the two operating systems because it was very easy to get rid of the duel boot option. Right now I'm reformatting my D drive where I had it installed. I also had to uninstall a lot of stuff from XP because they were installed on D drive, which I am now reformatting.

Anyone considerinstalling Vista -- don't. You will have nothing but headaches.

Salem commented: Hasta la VISTA baby +20
Nick Evan commented: Good advice! +8
The Dude commented: Xcellent thread and good advice Dragon :) +8
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

search www.microsoft.com for CListBox. You can find everything you need there, and for all the windows classes. You should use that for all your MFC questions, if you can't find it there then post question here. There is a lot of things though that MSDN doesn't tell you.

You should also be able to just press <F1> while in the compiler's IDE and it will take you right to the search box. I'm being a little bit evasive because you need to learn how to look it up yourself.

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

yes, and yes. If you want to know how to change the listbox contents, just read the methods that are available and you will find it (I don't recall off the top of my head.)

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

>>Can I do easily a dll for windows without using Microsoft Visual C++ compiler ?
yes, you can use most any compiler that targets MS-Windows version 2000 or later.

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

I always have problems using fstream too. So I try to avoid it and use ifstream or ofstream instead.

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

You can add controls, but it might be easier to use CFormView which is derived from CView but acts like CDialog.

To add a button to your CView, just create an instance of CButton in the CView's class, then when initializing CView class call the button's Create() method. Of course before calling Create() you will have to create a CRect (or just RECT) which you pass to Create(). I don't have an example to show you but its not all that difficult to do. It may take a few tries to get the CRect coordinates just right because you can't do it visually like you do with CDialog or CFormView.

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

Instead of sending the string returned by asctime() why now just convert the integer returned by time() to a string and send that? Then on client side just convert back to int and use it to change the computer's clock. If client needs the string returned by asctime() then it can get it itself from the string you send that was returned by time().

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

>>its not lettin others applications to run..

>>i cant use it bec we are workin on realtime systems

Do you mean you can't because the os doesn't support it, or because you don't want to use it? If you want to let other applications run then you aren't making full use of a real-time os.

What operating system is this for anyway?

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

I've always seen the modes used as ios::in | ios::out | ios::app

So have I, but see the example here

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

when line 7 is changed as below it works ok

class A
{
private:
    int aa;
public:
    A(int a = 0){aa = a;} // <<< this is ok now.
    void set(int x) {aa = x;}
};