Sup guys...I tried to make a little program my brother asked for to try and increase his odds of winning the lotto! lol...
anywho, It compiles and runs fine on my computer, but I tried it on two different computers running XP, and it doesnt work =(
Both computers I tried it on were XP, but come to think of it, one is an x64, and the other may be also...
anywho, here is the code:

#include "stdafx.h"
#include <fstream>
#include <iostream>
using namespace std;
struct PAIR
{
	UINT num1, num2;
	UINT lastdrawn;
};
int _tmain(int argc, _TCHAR* argv[])
{
	UINT R[20];
	UINT pair_matrix[71][71];
	UINT day = 1;
	PAIR pairs[4900];
	ofstream fout;
	ifstream fin;

	cout << "Initializing.....";
	
	memset(&pair_matrix[0], 0, 71*71*sizeof(UINT));
	memset(&pairs, 0, 4900*sizeof(PAIR));

	cout << "Done" << endl;

	cout << "Opening results.txt.....";
	
	fin.open("results.txt");
	
	if(!fin.is_open())
	{
		cout << "Could not open results.txt. Exiting program..." << endl;
		system("pause");
		return 0;
	}

	cout << "Success" << endl;

	cout << "Scanning numbers.....";

	while (!fin.eof())
	{
		fin >> R[0];
		if(R[0] == 0) continue;

		fin >> R[1] >> R[2] >> R[3] >> R[4] >> R[5] >> R[6] >> R[7] >> R[8] >> R[9] >> R[10]
			>> R[11] >> R[12] >> R[13] >> R[14] >> R[15] >> R[16] >> R[17] >> R[18] >> R[19];

		for(int x = 0; x < 19; x++)
			for(int y = x+1; y < 20; y++)
				if(pair_matrix[R[x]][R[y]] == 0)
					pair_matrix[R[x]][R[y]] = day;
		day++;
	}

	cout << "Finished" << endl;

	cout << "Building pair list.....";

	fout.open("pairs.txt");
	for(int x = 1; x <= 69; x++)
	{
		for(int y = x+1; y <= 70; y++)
		{
			for(int p = 0; p < 4900; p++)
			{
				if(pair_matrix[x][y] > pairs[p].lastdrawn)
				{
					for(int b = 4900-1; b > p; b--)
					{
						pairs[b] = pairs[b-1];
					}
					pairs[p].lastdrawn = pair_matrix[x][y];
					pairs[p].num1 = x;
					pairs[p].num2 = y;
					break;
				}
			}
		}
	}
	fout << " |last drawn|    |pair|" << endl;
	for(int p = 4899; p >= 0; p--)
	{
		if(pairs[p].num1 != 0)
		{
			fout << "       " << pairs[p].lastdrawn << "        (" << pairs[p].num1 << ", " << pairs[p].num2 << ")" << endl;
		}
	}

	fout.close();
	fin.close();

	cout << "Finished." << endl << "Statistics were saved in pairs.txt" << endl;

	system("pause");
	return 1;
}

is there any reason that this shouldn't work on Windows XP? or could it be because of the x64 cpu? when I ran it on the other computer (when my roomie took a run to the corner store lol) it said something about bad configuration...
thanks for any help =)

btw: I am comiling and running it on Vista home basic.

I attached a zip folder with the compiled bancostat.exe and "results.txt"

I wasn't sure what you meant by "data file"...you did mean the results file that is read in when the program executes right?

I compiled and ran your program on 64-bit Vista. This is the results

Initializing.....Done
Opening results.txt.....Success
Scanning numbers.....Finished
Building pair list.....Finished.
Statistics were saved in pairs.txt
Press any key to continue . . .

I did not run the exe file in your zip file.

>>but I tried it on two different computers running XP, and it doesnt work =(

What exactly do you mean by "it doesn't work"? Did you compile your program for debug or release. If for debug then the other computers more than likely do not have the correct Microsoft debug DLLs. Compile for release mode and try it again.

Ok! I wrote it down.
When I try it on my roomie's computer it says:
"
E:\bancostat.exe
This applicatiton has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.
"

and my brother says his computer gives a message something like "Can't run in ms dos"

I did compile in release mode, and the problem occurred with default settings before I tried changing any settings around.

=/

-edit...do you think maybe I am forgetting something? Should I just make a new project and choose Win32 console app, and slap my code back in there and try again? Is win32 even the correct mode to make a universally usable dos console app? or should I try downloading some older dos compiler or something?

If you're using VS, try changing the runtime library to what is shown in my screenshot, while making sure the mode is set to release.

Hope this helps.

Attachments Untitled.jpg 115.75 KB

OK! Thanks. /MT seems to have worked. It works on my roomie's comp, and I'm waiting for my bro to reply. I have a question though. Originally, the file size was like 11.5k compiled. After changing that option, the file size jumped way up to 154k! could you explain in a few words what I have just done? or should I google it?

thanks for the help =)

In short I guess it just includes more code in the actual executable file instead of relying on other dll's which your brother doesn't seem to have on his PC. I always compile on /MT as it just increases the portability of the program for a small sacrifice of about 100kb.

Edit:: Direct after replying I noticed the date of the last post.
Edit:: However, this might still be a useful advice for anyone who reads the thread.

Bad coding practices!

  1. !fin.eof() Check out this.
  2. system("pause"); Check out this.
    You could use cin.get() as a replacement.
  3. return 1; Why would you want to return value 1 if your program has terminated correctly?
    Make it return 0;

:)

This article has been dead for over six months. Start a new discussion instead.