what is wrong with me

buzzard34

Gawd
Joined
Feb 14, 2004
Messages
619
I can't fix it and it nearly drove me to drink due to the sheer amount of errors generated. I seriously doubt my knowledge of this C++ and i can't get help at all. wtf am I supposed to do its due tomorrow morning:

#include <iostream>
using namespace std;

void GetInput (double& eightDigit);

void ShowResults (double eightDigit, double cDigit);

char CheckDigitOne (int eightDigit);
//Precondition: eightDigit is an 8-digit integer. No error
//checking on this input is done.
//Postcondition: An upper case letter is determined
//according to the rules above and returned.

void CheckDigitTwo (int eightDigit, char& ch);
//Precondition: eightDigit is an 8-digit integer. No error
//checking on this input is done.
//Postcondition: ch is an upper case letter determined
//according to the rules above.


int main()
{
int eightDigit, workingnumber,remains,TwoDigitOne,TwoDigitTwo,TwoDigitThree,TwoDigitFour;
char cDigit, answer;
do
{GetInput (eightDigit);
cDigit = CheckDigitOne;
cout << endl << endl <<"First results.\n";
ShowResults(eightDigit,cDigit);

cDigit = 0;
CheckDigitTwo(eightDigit, char ch);
cout << endl << endl <<"The second result.\n";
cout << "Would you like another go around?"
<<"Please press y for yes, any other key for no";
cin >> answer;
}while((answer=='Y')||(answer=='y'));
return 0;
}

void GetInput (const double& eightDigit)
{bool valid;
do
{
cout << "Please enter your 8-digit number now";
cin >> eightDigit;
valid=(eightDigit>10000000)&&(eightDigit<99999999);
if (!valid)
cout << "Sorry, try again.";
}
while (!valid);
}

void ShowResults (double eightDigit, char& ch)
{
cout << "Your new ID number is" << eightDigit
<< "with appended check digit (or character)" << cDigit
<< "Keep this number!\n";
}

double CheckDigitOne(int eightDigit)
(
return
int eightDigit, workingnumber,remains, TwoDigitOne,TwoDigitTwo,TwoDigitThree,TwoDigitFour;
char cDigit;

cout << "Enter your 8-digit ID number now.\n";
cin >> eightDigit;

workingnumber = eightDigit;
TwoDigitFour = workingnumber % 100;
workingnumber = workingnumber / 100;
TwoDigitThree = workingnumber % 100;
workingnumber = workingnumber / 100;
TwoDigitTwo = workingnumber % 100;
workingnumber = workingnumber / 100;
TwoDigitOne = workingnumber % 100;

remains = (TwoDigitOne+TwoDigitTwo+TwoDigitThree+TwoDigitFour) % 26;

cDigit = 'A' + remains;
}

void CheckDigitTwo (int& eightDigit, char& ch)
{
cDigit =
int eightDigit, workingnumber,remains, TwoDigitOne, TwoDigitTwo, TwoDigitThree, TwodigitFour;
char cDigit;

cout << "Enter your 8-digit ID number now.\n";
cin >> eightDigit;

workingnumber = eightDigit;
TwoDigitFour = workingnumber % 100;
workingnumber = workingnumber / 100;
TwoDigitThree = workingnumber % 100;
workingnumber = workingnumber / 100;
TwoDigitTwo = workingnumber % 100;
workingnumber = workingnumber / 100;
TwoDigitOne = workingnumber % 100;

remains = (TwoDigitOne+TwoDigitTwo+TwoDigitThree+TwoDigitFour) % 26;

cDigit = 'A' + remains;
}
Its functions. fuck it im am changing my major come semester i CANT STAND coding.:mad: I want help but nobody is going to be able to clarify this convulted mess of code. :(
 
now that I've calmed down some, lemme explain: I have to write a check digit program using user-defined functions. I have not done well at all on previous assignments and could only redo them after looking at someone's source code which is totally different than mine. Am i overthinking this shit or what?
 
Q: What is wrong with you?

A: You are taking a class you do not like / enjoy / not good at. Drop it. Thank me later.
 
akapaulk said:
Q: What is wrong with you?

A: You are taking a class you do not like / enjoy / not good at. Drop it. Thank me later.
i guess so. I hope being an electrical engineer is as fun as being a comp engineer:( I don't think there's any way around getting out of that class and still getting a CE degree.
 
Code:
void GetInput (const double& eightDigit)

i haven't done any C++ in a while, and i was never good with it to begin with, but in the function GetInput() you pass in eigthtDigit by reference but declare it as an int when the function calls for a double. you also declare the reference as const, and i always get confused by the various types of constants you can use, but i think in this context you're saying eightDigit is not to be modified by the function, yet that's exactly what you try to do with cin>>eightDigit

that's about as far in as i got, and as i said i'm not really the person to be giving out C++ advice. i can say confidently however that if you dislike programming so much you should definetely find another field. even people who DO like to program can find it quite aggravating and consuming. i generally have to brace myself before working on my various perl projects, but truly it's something i love to do and that the only thing that keep me doing it.
 
fluxion said:
Code:
void GetInput (const double& eightDigit)

i haven't done any C++ in a while, and i was never good with it to begin with, but in the function GetInput() you pass in eigthtDigit by reference but declare it as an int when the function calls for a double. you also declare the reference as const, and i always get confused by the various types of constants you can use, but i think in this context you're saying eightDigit is not to be modified by the function, yet that's exactly what you try to do with cin>>eightDigit

that's about as far in as i got, and as i said i'm not really the person to be giving out C++ advice. i can say confidently however that if you dislike programming so much you should definetely find another field. even people who DO like to program can find it quite aggravating and consuming. i generally have to brace myself before working on my various perl projects, but truly it's something i love to do and that the only thing that keep me doing it.
wow. that alone makes me want to cry.
/goes off to find a way to get out of this class ASAP
 
Wow, are you afraid of whitespace? Using tabs and empty lines liberally will help you figure out what's wrong with your code.

I want help but nobody is going to be able to clarify this convulted mess of code.

That sounds like a challenge. Here it is, but more readable (tabs and lines added, nothing else)

Code:
 #include <iostream>
using namespace std;

void GetInput (double& eightDigit);

void ShowResults (double eightDigit, double cDigit);

char CheckDigitOne (int eightDigit);
//Precondition: eightDigit is an 8-digit integer. No error
//checking on this input is done.
//Postcondition: An upper case letter is determined
//according to the rules above and returned.

void CheckDigitTwo (int eightDigit, char& ch);
//Precondition: eightDigit is an 8-digit integer. No error
//checking on this input is done.
//Postcondition: ch is an upper case letter determined
//according to the rules above.


int main(){

	int eightDigit, workingnumber,remains,TwoDigitOne,TwoDigitTwo,TwoDigitThree,TwoDigitFour;
	char cDigit, answer;
	do {
		GetInput (eightDigit);
		cDigit = CheckDigitOne;
		cout << endl << endl <<"First results.\n";
		ShowResults(eightDigit,cDigit);

		cDigit = 0;
		CheckDigitTwo(eightDigit, char ch);
		cout << endl << endl <<"The second result.\n";
		cout << "Would you like another go around?"
		<<"Please press y for yes, any other key for no";
		cin >> answer;
	} while((answer=='Y')||(answer=='y'));

	return 0;
}

void GetInput (const double& eightDigit){
	bool valid;
	do {
		cout << "Please enter your 8-digit number now";
		cin >> eightDigit;
		valid=(eightDigit>10000000)&&(eightDigit<99999999);

		if (!valid)
			cout << "Sorry, try again.";
	} while (!valid);
}

void ShowResults (double eightDigit, char& ch){
	cout << "Your new ID number is" << eightDigit
	<< "with appended check digit (or character)" << cDigit
	<< "Keep this number!\n";
}

double CheckDigitOne(int eightDigit)(
	return
	int eightDigit, workingnumber,remains, TwoDigitOne,TwoDigitTwo,TwoDigitThree,TwoDigitFour;
	char cDigit;

	cout << "Enter your 8-digit ID number now.\n";
	cin >> eightDigit;

	workingnumber = eightDigit;
	TwoDigitFour = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitThree = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitTwo = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitOne = workingnumber % 100;

	remains = (TwoDigitOne+TwoDigitTwo+TwoDigitThree+TwoDigitFour) % 26;

	cDigit = 'A' + remains;
}

void CheckDigitTwo (int& eightDigit, char& ch){
	cDigit =
	int eightDigit, workingnumber,remains, TwoDigitOne, TwoDigitTwo, TwoDigitThree, TwodigitFour;
	char cDigit;

	cout << "Enter your 8-digit ID number now.\n";
	cin >> eightDigit;

	workingnumber = eightDigit;
	TwoDigitFour = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitThree = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitTwo = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitOne = workingnumber % 100;

	remains = (TwoDigitOne+TwoDigitTwo+TwoDigitThree+TwoDigitFour) % 26;

	cDigit = 'A' + remains;
}

The first thing I notice is that you don't really know what the double datatype is for. It is for numbers involving decimal places: eg, 3.1415. If you're just using whole numbers, stick to int

You also don't seem to understand the different between pointers and scalars. You might want to get your teacher to explain those to you, or find an online tutorial of some sort.

Third, it looks like you've not finished your code. There are constructs like "cDigit =" (line 83), and a rogue "return" on line 61.

Do you have some sort of example of what the code should output? I can't really tell from your code that well, but it seems to have something to do with adding a validation digit to the end of an ID number.
 
This actually is not that bad. If you wrote this by yourself you posses more knowledge of C++ than I would expect of someone who just started learning it this semester. Give me a little bit and I will turn what you have into a working program making as few changes possible and I will give you a summary of what had to be changed...
 
Lews_Therin said:
Wow, are you afraid of whitespace? Using tabs and empty lines liberally will help you figure out what's wrong with your code.



That sounds like a challenge. Here it is, but more readable (tabs and lines added, nothing else)

Code:
 #include <iostream>
using namespace std;
 
void GetInput (double& eightDigit);
 
void ShowResults (double eightDigit, double cDigit);
 
char CheckDigitOne (int eightDigit);
//Precondition: eightDigit is an 8-digit integer. No error
//checking on this input is done.
//Postcondition: An upper case letter is determined
//according to the rules above and returned.
 
void CheckDigitTwo (int eightDigit, char& ch);
//Precondition: eightDigit is an 8-digit integer. No error
//checking on this input is done.
//Postcondition: ch is an upper case letter determined
//according to the rules above.
 
 
int main(){
 
	int eightDigit, workingnumber,remains,TwoDigitOne,TwoDigitTwo,TwoDigitThree,TwoDigitFour;
	char cDigit, answer;
	do {
		GetInput (eightDigit);
		cDigit = CheckDigitOne;
		cout << endl << endl <<"First results.\n";
		ShowResults(eightDigit,cDigit);
 
		cDigit = 0;
		CheckDigitTwo(eightDigit, char ch);
		cout << endl << endl <<"The second result.\n";
		cout << "Would you like another go around?"
		<<"Please press y for yes, any other key for no";
		cin >> answer;
	} while((answer=='Y')||(answer=='y'));
 
	return 0;
}
 
void GetInput (const double& eightDigit){
	bool valid;
	do {
		cout << "Please enter your 8-digit number now";
		cin >> eightDigit;
		valid=(eightDigit>10000000)&&(eightDigit<99999999);
 
		if (!valid)
			cout << "Sorry, try again.";
	} while (!valid);
}
 
void ShowResults (double eightDigit, char& ch){
	cout << "Your new ID number is" << eightDigit
	<< "with appended check digit (or character)" << cDigit
	<< "Keep this number!\n";
}
 
double CheckDigitOne(int eightDigit)(
	return
	int eightDigit, workingnumber,remains, TwoDigitOne,TwoDigitTwo,TwoDigitThree,TwoDigitFour;
	char cDigit;
 
	cout << "Enter your 8-digit ID number now.\n";
	cin >> eightDigit;
 
	workingnumber = eightDigit;
	TwoDigitFour = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitThree = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitTwo = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitOne = workingnumber % 100;
 
	remains = (TwoDigitOne+TwoDigitTwo+TwoDigitThree+TwoDigitFour) % 26;
 
	cDigit = 'A' + remains;
}
 
void CheckDigitTwo (int& eightDigit, char& ch){
	cDigit =
	int eightDigit, workingnumber,remains, TwoDigitOne, TwoDigitTwo, TwoDigitThree, TwodigitFour;
	char cDigit;
 
	cout << "Enter your 8-digit ID number now.\n";
	cin >> eightDigit;
 
	workingnumber = eightDigit;
	TwoDigitFour = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitThree = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitTwo = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitOne = workingnumber % 100;
 
	remains = (TwoDigitOne+TwoDigitTwo+TwoDigitThree+TwoDigitFour) % 26;
 
	cDigit = 'A' + remains;
}

The first thing I notice is that you don't really know what the double datatype is for. It is for numbers involving decimal places: eg, 3.1415. If you're just using whole numbers, stick to int

You also don't seem to understand the different between pointers and scalars. You might want to get your teacher to explain those to you, or find an online tutorial of some sort.

Third, it looks like you've not finished your code. There are constructs like "cDigit =" (line 83), and a rogue "return" on line 61.

Do you have some sort of example of what the code should output? I can't really tell from your code that well, but it seems to have something to do with adding a validation digit to the end of an ID number.
It should return something like 12346578Y and then ask the user if they wish to input another 8 digit number or not.
 
void GetInput (const double& eightDigit){

You are passing by reference yet declaring eightDigit as const, which is saying "I'm not going to mess with that value"

Then you mess with the value. That's one simple error.

Not to mention you are passing an integer in main() yet it's expecting to receive a double.
 
Here is my solution. It compiles and runs and functions as it should as far as I can tell, though I don't know why you call two seperate checkDigit functions that do the same thing? Compare it to your original and ask me about anything you don't understand.

Code:
#include <iostream>
using namespace std;

void GetInput(int&);

void ShowResults(int, char);

char CheckDigitOne(int);
//Precondition: eightDigit is an 8-digit integer. No error
//checking on this input is done.
//Postcondition: An upper case letter is determined
//according to the rules above and returned.

void CheckDigitTwo(int, char);
//Precondition: eightDigit is an 8-digit integer. No error
//checking on this input is done.
//Postcondition: ch is an upper case letter determined
//according to the rules above.


int main()
{
	int eightDigitNum;
	char cDigit, answer;

	do
	{
		GetInput(eightDigitNum);
		cDigit = CheckDigitOne(eightDigitNum);
		cout << endl <<"First results:" << endl;
		ShowResults(eightDigitNum,cDigit);

		CheckDigitTwo(eightDigitNum, cDigit);
		cout << endl <<"Second result:" << endl;
		ShowResults(eightDigitNum,cDigit);

		cout << endl << "Would you like another go around? Please press y for yes, any other key for no: ";
		cin >> answer;
	}while(answer=='Y' || answer=='y');

	return 0;
}



void GetInput(int& eightDigitNum)
{
	bool valid = false;
	
	do
	{
		cout << "Please enter your 8-digit number now: ";
		cin >> eightDigitNum;
		if(eightDigitNum>=10000000 && eightDigitNum<=99999999)valid = true;
		if(!valid) cout << endl << "Sorry, try again." << endl;
	}while (!valid);
}


void ShowResults(int eightDigitNum, char ch)
{
	cout << "Your new ID number is: " << eightDigitNum 
		<< " with appended check letter: " << ch << " Keep this number!\n";
}


char CheckDigitOne(int eightDigitNum)
{
	int workingnumber, remains, TwoDigitOne,TwoDigitTwo,TwoDigitThree,TwoDigitFour;
	//char cDigit;

	//cout << "Enter your 8-digit ID number now.\n";
	//cin >> eightDigit;

	workingnumber = eightDigitNum;
	TwoDigitFour = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitThree = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitTwo = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitOne = workingnumber % 100;

remains = (TwoDigitOne+TwoDigitTwo+TwoDigitThree+TwoDigitFour) % 26;

return('A' + remains);
}


void CheckDigitTwo (int eightDigitNum, char ch)
{
	int workingnumber, remains, TwoDigitOne, TwoDigitTwo, TwoDigitThree, TwoDigitFour;

	workingnumber = eightDigitNum;
	TwoDigitFour = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitThree = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitTwo = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitOne = workingnumber % 100;

	remains = (TwoDigitOne+TwoDigitTwo+TwoDigitThree+TwoDigitFour) % 26;
	ch = 'A' + remains;
}

And here is the result of execution:

Code:
Please enter your 8-digit number now: 12345678

First results:
Your new ID number is: 12345678 with appended check letter: Y Keep this number!

Second result:
Your new ID number is: 12345678 with appended check letter: Y Keep this number!

Would you like another go around? Please press y for yes, any other key for no:

It's not as pretty as I would like it and I would LOVE to change some of those variable names (more than I did) but I said I would try to keep it as close to the original as possible.
 
CHollman82 said:
Here is my solution. It compiles and runs and functions as it should as far as I can tell, though I don't know why you call two seperate checkDigit functions that do the same thing? Compare it to your original and ask me about anything you don't understand.

Code:
#include <iostream>
using namespace std;
 
void GetInput(int&);
 
void ShowResults(int, char);
 
char CheckDigitOne(int);
//Precondition: eightDigit is an 8-digit integer. No error
//checking on this input is done.
//Postcondition: An upper case letter is determined
//according to the rules above and returned.
 
void CheckDigitTwo(int, char);
//Precondition: eightDigit is an 8-digit integer. No error
//checking on this input is done.
//Postcondition: ch is an upper case letter determined
//according to the rules above.
 
 
int main()
{
	int eightDigitNum;
	char cDigit, answer;
 
	do
	{
		GetInput(eightDigitNum);
		cDigit = CheckDigitOne(eightDigitNum);
		cout << endl <<"First results:" << endl;
		ShowResults(eightDigitNum,cDigit);
 
		CheckDigitTwo(eightDigitNum, cDigit);
		cout << endl <<"Second result:" << endl;
		ShowResults(eightDigitNum,cDigit);
 
		cout << endl << "Would you like another go around? Please press y for yes, any other key for no: ";
		cin >> answer;
	}while(answer=='Y' || answer=='y');
 
	return 0;
}
 
 
 
void GetInput(int& eightDigitNum)
{
	bool valid = false;
 
	do
	{
		cout << "Please enter your 8-digit number now: ";
		cin >> eightDigitNum;
		if(eightDigitNum>=10000000 && eightDigitNum<=99999999)valid = true;
		if(!valid) cout << endl << "Sorry, try again." << endl;
	}while (!valid);
}
 
 
void ShowResults(int eightDigitNum, char ch)
{
	cout << "Your new ID number is: " << eightDigitNum 
		<< " with appended check letter: " << ch << " Keep this number!\n";
}
 
 
char CheckDigitOne(int eightDigitNum)
{
	int workingnumber, remains, TwoDigitOne,TwoDigitTwo,TwoDigitThree,TwoDigitFour;
	//char cDigit;
 
	//cout << "Enter your 8-digit ID number now.\n";
	//cin >> eightDigit;
 
	workingnumber = eightDigitNum;
	TwoDigitFour = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitThree = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitTwo = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitOne = workingnumber % 100;
 
remains = (TwoDigitOne+TwoDigitTwo+TwoDigitThree+TwoDigitFour) % 26;
 
return('A' + remains);
}
 
 
void CheckDigitTwo (int eightDigitNum, char ch)
{
	int workingnumber, remains, TwoDigitOne, TwoDigitTwo, TwoDigitThree, TwoDigitFour;
 
	workingnumber = eightDigitNum;
	TwoDigitFour = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitThree = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitTwo = workingnumber % 100;
	workingnumber = workingnumber / 100;
	TwoDigitOne = workingnumber % 100;
 
	remains = (TwoDigitOne+TwoDigitTwo+TwoDigitThree+TwoDigitFour) % 26;
	ch = 'A' + remains;
}

And here is the result of execution:

Code:
Please enter your 8-digit number now: 12345678
 
First results:
Your new ID number is: 12345678 with appended check letter: Y Keep this number!
 
Second result:
Your new ID number is: 12345678 with appended check letter: Y Keep this number!
 
Would you like another go around? Please press y for yes, any other key for no:

It's not as pretty as I would like it and I would LOVE to change some of those variable names (more than I did) but I said I would try to keep it as close to the original as possible.
How did you do that? See, thats what I have trouble with I can't tell where I went wrong even though the compiler says " check line xx for error xxxxx"
 
One thing I did notice after I tried to compile it as is was that more than half of the errors you were getting were caused by a " ( " being used to start a function rather than a " { ". C++ is like this, one thing wrong can cause literally thousands of errors, and I've seen that before trust me.

Another major thing is that you do not want to use double for your ID number (eightDigit). Double is basically a long float, it is used with numbers that will require a decimal point. The int data type is 32 bit as well as the long data type on modern compilers. 32 bits can hold a maximum value of 4294967296 (which equals exactly 4 Gigabytes), which is plenty big enough to hold an 8 digit number. If you were using an older compiler where int was 16 bit you would need to use a long to hold an 8 digit number. For integer values it goes like this: short, int, long
For floating point (decimal) values its this: float, double.
Then you get into signed and unsigned but don't worry about that.

Umm, let me think, what else.... Oh, you were passing eightDigit by reference to every function. Variables only have to be passed by reference when there value is going to change in the function and you want that change to be reflected in the original variable when the function returns. In this case it is necessary to pass by reference only in the getInput function because you are setting (changing) the value of eightDigit, in the other functions you are only using it, not changing it, therefore the variable can be passed normally.

Thats really about it aside from syntax errors (forgotten semicolons, the ( instead of { etc etc.) and thats stuff even I do all the time. To help that learn to compile your program as each chunk is completed, and debug it as you go instead of waiting till its done and seeing every error at once.
 
Here, this will probably help you more than just looking at mine.

Code:
#include <iostream>
using namespace std;


void GetInput ([COLOR=Red]double[/COLOR]& eightDigit); 
[COLOR=DeepSkyBlue]double should be int.[/COLOR]


void ShowResults ([COLOR=Red]double[/COLOR] eightDigit, double cDigit); 
[COLOR=DeepSkyBlue]double should be int[/COLOR]

char CheckDigitOne (int eightDigit);

void CheckDigitTwo (int eightDigit, char& ch); 

int main()
{
int eightDigit; 

[COLOR=Red]workingnumber,remains,TwoDigitOne,TwoDigitTwo,TwoDigitThree,TwoDigitFour[/COLOR];
[COLOR=DeepSkyBlue]These variables are never used in main and therefore do not need to be declared here[/COLOR]

char cDigit, answer;

do
{
GetInput(eightDigit);
cDigit = CheckDigitOne;
cout << endl << endl <<"First results.\n";
ShowResults(eightDigit,cDigit);

[COLOR=Red]cDigit = 0;[/COLOR]
[COLOR=DeepSkyBlue]This is unnecessary, though it doesn't hurt anything[/COLOR]


CheckDigitTwo(eightDigit, [COLOR=Red]char ch[/COLOR]);
[COLOR=DeepSkyBlue]You should pass cDigit into this by reference, not a new char value[/COLOR]


cout << endl << endl <<"The second result.\n";

[COLOR=DeepSkyBlue]You forgot to add a call to ShowResults here[/COLOR]

cout << "Would you like another go around?"
<<"Please press y for yes, any other key for no";
cin >> answer;

}[COLOR=Red]while((answer=='Y')||(answer=='y'));[/COLOR]
[COLOR=DeepSkyBlue]The extra set of paranthesis is not necessary, though it doesn't hurt anything[/COLOR]

return 0;
}

void GetInput ([COLOR=Red]const double&[/COLOR] eightDigit)
[COLOR=DeepSkyBlue]This should be int&, not const double&[/COLOR]

{

[COLOR=Red]bool valid;[/COLOR]
[COLOR=DeepSkyBlue]Valid needs to be initialized to false: bool valid = false;[/COLOR]

do
{
cout << "Please enter your 8-digit number now";
cin >> eightDigit;

[COLOR=Red]valid=(eightDigit>10000000)&&(eightDigit<99999999);[/COLOR]
[COLOR=DeepSkyBlue]This doesn't work at all and is one of the major problems I saw. You need to do it like this:
if(eightDigit>=10000000 && eightDigit<=99999999) valid=true[/COLOR]

if (!valid) cout << "Sorry, try again.";
}
while (!valid);
}

[COLOR=Red]void ShowResults (double eightDigit, char& ch)[/COLOR]
[COLOR=DeepSkyBlue]Double should be int, char ch does not need to be passed by reference[/COLOR]

{
cout << "Your new ID number is" << eightDigit
<< "with appended check digit (or character)" << [COLOR=Red]cDigit[/COLOR]
[COLOR=DeepSkyBlue]This needs to be the char ch value you passed into the function, cDigit cannot be accessed here.[/COLOR]

<< "Keep this number!\n";
}

[COLOR=Red]double[/COLOR] CheckDigitOne(int eightDigit)
[COLOR=DeepSkyBlue]This should return a char not a double[/COLOR]

[COLOR=Red]([/COLOR]
[COLOR=DeepSkyBlue]This caused half the errors in your program, lol. It should be {[/COLOR]

[COLOR=Red]return[/COLOR]
[COLOR=DeepSkyBlue]This does nothing and shouldn't be here[/COLOR]

int eightDigit, workingnumber,remains, TwoDigitOne,TwoDigitTwo,TwoDigitThree,TwoDigitFour;
[COLOR=Red]char cDigit;[/COLOR]
[COLOR=DeepSkyBlue]this variable is not used here and doesn't need to be declared[/COLOR]

[COLOR=Red]cout << "Enter your 8-digit ID number now.\n";
cin >> eightDigit;[/COLOR]
[COLOR=DeepSkyBlue]You already have the 8 digit number they entered first, you don't need to ask for it again[/COLOR]

workingnumber = eightDigit;
TwoDigitFour = workingnumber % 100;
workingnumber = workingnumber / 100;
TwoDigitThree = workingnumber % 100;
workingnumber = workingnumber / 100;
TwoDigitTwo = workingnumber % 100;
workingnumber = workingnumber / 100;
TwoDigitOne = workingnumber % 100;

remains = (TwoDigitOne+TwoDigitTwo+TwoDigitThree+TwoDigitFour) % 26;

[COLOR=Red]cDigit = 'A' + remains;[/COLOR]
[COLOR=DeepSkyBlue]Instead of declaring dDigit, setting it equal to that, and then returning it, all you have to do is return 'A' + remains like this return('A'+remains); In fact, you can combine that with how you computed remains and not even need the remains variable[/COLOR]
}

void CheckDigitTwo ([COLOR=Red]int&[/COLOR] eightDigit, char& ch)
[COLOR=DeepSkyBlue]eightDigit does not need to be passed by reference here[/COLOR]
{
[COLOR=Red]cDigit =[/COLOR]
[COLOR=DeepSkyBlue]This does nothing, and was generating a few errors[/COLOR]

int [COLOR=Red]eightDigit[/COLOR], workingnumber,remains, TwoDigitOne, TwoDigitTwo, TwoDigitThree, TwodigitFour;
[COLOR=DeepSkyBlue]eightDigit does not need to be declared, you passed it in already[/COLOR]

[COLOR=Red]char cDigit;[/COLOR]
[COLOR=DeepSkyBlue]This is unnecessary, you already have char ch passed into the function by reference for this purpose[/COLOR]

[COLOR=Red]cout << "Enter your 8-digit ID number now.\n";
cin >> eightDigit;[/COLOR]
[COLOR=DeepSkyBlue]Again, you don't need to ask them for the ID number, you already have it in the eightDigit variable[/COLOR]

workingnumber = eightDigit;
TwoDigitFour = workingnumber % 100;
workingnumber = workingnumber / 100;
TwoDigitThree = workingnumber % 100;
workingnumber = workingnumber / 100;
TwoDigitTwo = workingnumber % 100;
workingnumber = workingnumber / 100;
TwoDigitOne = workingnumber % 100;

remains = (TwoDigitOne+TwoDigitTwo+TwoDigitThree+TwoDigitFour) % 26;

[COLOR=Red]cDigit[/COLOR] = 'A' + remains;
[COLOR=DeepSkyBlue]This should be ch = 'A' + remains, ch was passed into the function by reference for this purpose[/COLOR]
}

See, it's really not that bad. Most of your errors we being generated by the same mistake, or the same mistake made over and over again. Also, you need to straighten out when you need to pass a variable by reference and when you don't. Aside from that the only other major thing I saw was that you were confusing variable scope so here is some info on that:

The scope of a variable is "how far away" that variable can be "seen". When you declare a variable in your main function, or any other function, it can only be used inside of that function. If you declare a variable outside of a function (typically after the #includes and before main()) it is called a global variable. Global variables can be seen in every function that follows it. If, for example, you needed to access a variable that was declared in main from some other function (checkDigit for example) you have to pass the variable to the function. You know this already. When you pass a variable it will create a copy of it that the recieving function can use. However, the recieving function cannot modify the variable, because it is only a copy, not the real thing. If you need to be able to modify a variable from a function other than the one it was declared in you need to pass it to the function by reference. What this does (and this is getting a little technical) is pass a pointer (the memory address that the variable data is stored at) to the function. This way, when the recieving function changes a variable passed by reference, the variable is actually changed and will reflect this change in the originating function.
 
Hey no problem. I just can't stand it when people get turned off to programming because of the ignorant way it is taught in our schools. Just look at that pile of crap, they could make the slightest effort to make the demo programs interesting, but no, you have to write math solvers and bank software, there will be enough of that once you get a job in the field :rolleyes:

They should be teaching you how to make graphical programs using mode 13h or how to write Win32 applications. Imagine by the end of your first programming class being able to write a fully functioning windows program (not black and white DOS console crap), and by the end of your second class being able to write a game using the DirectX API's. It would take about the same amount of time to teach that as to go through countless trivial console programs...
 
CHollman82 said:
Hey no problem. I just can't stand it when people get turned off to programming because of the ignorant way it is taught in our schools. Just look at that pile of crap, they could make the slightest effort to make the demo programs interesting, but no, you have to write math solvers and bank software, there will be enough of that once you get a job in the field :rolleyes:

They should be teaching you how to make graphical programs using mode 13h or how to write Win32 applications. Imagine by the end of your first programming class being able to write a fully functioning windows program (not black and white DOS console crap), and by the end of your second class being able to write a game using the DirectX API's. It would take about the same amount of time to teach that as to go through countless trivial console programs...
Well I know MacOSX is C based, so I was looking forward to at least creating some simple Mac apps...but I really think I'm gonna drop the class. I have far more interest in how a capacitor works than in how x>y proves greater than int double whatever. :D
 
Yeah but you can't do this with capacitors... My Particle Engine

I wrote this particle engine in my notebook during a particularly boring Unix class, took about 30 minutes from start to finish, then another 30 to type it into the compiler and tweak it a bit. I make stuff like this all the time. I am working on a DirectX game engine I can use to build games really quickly.

Controlls are as follows:
Arrow Keys: Change direction/spread of particle fountain
Insert/Delete: Add or remove particles (10-10,000)
Numpad +/-: Increase/decrease particle speed
Left Mouse Button: Increase Gravity
Right Mouse Button: Decrease Gravity
Middle Mouse Button: Zero Gravity
Mouse Wheel: Up - Increase gravity, Down - Decrease gravity
Space Bar (Hold): Slow Motion
Enter (Hold): Pause

(it only works on windows, you mentioned MAC...)
 
CHollman82 said:
Yeah but you can't do this with capacitors... My Particle Engine

I wrote this particle engine in my notebook during a particularly boring Unix class, took about 30 minutes from start to finish, then another 30 to type it into the compiler and tweak it a bit. I make stuff like this all the time. I am working on a DirectX game engine I can use to build games really quickly.

Controlls are as follows:
Arrow Keys: Change direction/spread of particle fountain
Insert/Delete: Add or remove particles (10-10,000)
Numpad +/-: Increase/decrease particle speed
Left Mouse Button: Increase Gravity
Right Mouse Button: Decrease Gravity
Middle Mouse Button: Zero Gravity
Mouse Wheel: Up - Increase gravity, Down - Decrease gravity
Space Bar (Hold): Slow Motion
Enter (Hold): Pause

(it only works on windows, you mentioned MAC...)
it works cuz I have a pc. thats really cool, I really couldn't make something like that cause I would get fustrated and give up...still going with EENG btw. How do you quit that progam, had to use taskmgr.
 
... since you are a programmer here is the code... :)

myDD.h
Code:
#define INITGUID
[COLOR=Red]#define WIN32_LEAN_AND_MEAN[/COLOR] // I LOVE THAT 

#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEYUP(vk_code)   ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)

#define RGB_16BIT565(r, g, b)  ((r << 11) | (g << 5) | (b))
#define RGB_16BIT555(r, g, b)  ((r << 10) | (g << 5) | (b))

#define SCREEN_WIDTH  1024
#define SCREEN_HEIGHT 768
#define SCREEN_BPP    16
#define NULL	0
#define RIGHT	1
#define	LEFT	2
#define DOWN	3
#define UP		4
#define WALLCOLOR 174

#define CLASS_NAME "whatever"

LPDIRECTDRAW7 lpdd;
DDSURFACEDESC2 ddsd;  
LPDIRECTDRAWSURFACE7 primarysurface;
LPDIRECTDRAWSURFACE7 backsurface;
LPDIRECTDRAWSURFACE7 level1;
LPDIRECTDRAWCLIPPER  lpddclipper;
HINSTANCE ghinstance;


LPDIRECTDRAWCLIPPER DDraw_Attach_Clipper(LPDIRECTDRAWSURFACE7 lpdds,
                                         int num_rects,
                                         LPRECT clip_list)

{
// this function creates a clipper from the sent clip list and attaches
// it to the sent surface

int index;                         // looping var
LPDIRECTDRAWCLIPPER lpddclipper;   // pointer to the newly created dd clipper
LPRGNDATA region_data;             // pointer to the region data that contains
                                   // the header and clip list

// first create the direct draw clipper
if (FAILED(lpdd->CreateClipper(0,&lpddclipper,NULL)))
   return(NULL);

// now create the clip list from the sent data

// first allocate memory for region data
region_data = (LPRGNDATA)malloc(sizeof(RGNDATAHEADER)+num_rects*sizeof(RECT));

// now copy the rects into region data
memcpy(region_data->Buffer, clip_list, sizeof(RECT)*num_rects);

// set up fields of header
region_data->rdh.dwSize          = sizeof(RGNDATAHEADER);
region_data->rdh.iType           = RDH_RECTANGLES;
region_data->rdh.nCount          = num_rects;
region_data->rdh.nRgnSize        = num_rects*sizeof(RECT);

region_data->rdh.rcBound.left    =  64000;
region_data->rdh.rcBound.top     =  64000;
region_data->rdh.rcBound.right   = -64000;
region_data->rdh.rcBound.bottom  = -64000;

// find bounds of all clipping regions
for (index=0; index<num_rects; index++)
    {
    // test if the next rectangle unioned with the current bound is larger
    if (clip_list[index].left < region_data->rdh.rcBound.left)
       region_data->rdh.rcBound.left = clip_list[index].left;

    if (clip_list[index].right > region_data->rdh.rcBound.right)
       region_data->rdh.rcBound.right = clip_list[index].right;

    if (clip_list[index].top < region_data->rdh.rcBound.top)
       region_data->rdh.rcBound.top = clip_list[index].top;

    if (clip_list[index].bottom > region_data->rdh.rcBound.bottom)
       region_data->rdh.rcBound.bottom = clip_list[index].bottom;

    } // end for index

// now we have computed the bounding rectangle region and set up the data
// now let's set the clipping list

if (FAILED(lpddclipper->SetClipList(region_data, 0)))
   {
   // release memory and return error
   free(region_data);
   return(NULL);
   } // end if

// now attach the clipper to the surface
if (FAILED(lpdds->SetClipper(lpddclipper)))
   {
   // release memory and return error
   free(region_data);
   return(NULL);
   } // end if

// all is well, so release memory and send back the pointer to the new clipper
free(region_data);
return(lpddclipper);
}

Particles.h
Code:
int xrandmod = -50;
int yrandmod = -100;
float speed = 200.0;
int GRAVITY = 0;
int COLORSET = 1;

class Particle
{
public:

	float x,y,dirx,diry,r,g,b;

	Particle()
	{
		x = SCREEN_WIDTH/2;
		y = SCREEN_HEIGHT/2;
		dirx = (rand() % 50) + xrandmod;
		diry = (rand() % 200) + yrandmod;
		if(COLORSET==1){r=31; g=63; b=31;}
		else if(COLORSET==2){r=rand()%255; g=rand()%255; b=rand()%255;}
		else if(COLORSET==3){r=31;g=0;b=0;}
		else if(COLORSET==4){r=31;g=63;b=31;}
	}

	Particle(float xa, float ya, float dirxa, float dirya)
	{
		x=xa; y=ya; dirx=dirxa; diry=dirya;
		yrandmod = -150;
	}

	void Move(USHORT* buffer, int nPitch)
	{
		//First, erase the particle
		Erase(buffer, nPitch);
		
		//Update the particles position
		x+=(dirx/speed);
		y+=(diry/speed);
		diry+=GRAVITY;

		//Check to make sure the particle is still on the screen, if not reset it
		if(y>SCREEN_HEIGHT-5)Reset();
		if(x<5 && dirx<0)dirx+=(dirx*-2);
		if(x>SCREEN_WIDTH-5 && dirx>0)dirx-=(dirx*2);
		if(y<5 && diry<0)diry+=(diry*-2);
		//if(y>SCREEN_HEIGHT-5 && diry>0)diry-=(diry*2);
		
		//Draw the particle at its new position
		Draw(buffer, nPitch);
	}

	void Draw(USHORT* buffer, int nPitch)
	{
		//Convert the color to 16bit 565 format
		int color=RGB_16BIT565((int)r,(int)g,(int)b);
		
		//Draw 4 pixels in a square with x,y being the upper left
		buffer[(int)y*nPitch + (int)x] = color;
		buffer[(int)(y+1)*nPitch + (int)x] = color;
		buffer[(int)y*nPitch + (int)x+1] = color;
		buffer[(int)(y+1)*nPitch + (int)x+1] = color;
		
		//Fade out white -> black
		if(COLORSET==1) 
		{
			if(r>0)r-=.1;
			if(g>0)g-=.2;
			if(b>0)b-=.1;
		}

		//No fading
		else if(COLORSET==2); 

		//Fade out red -> black
		else if(COLORSET==3) 
		{
			if(r>0)r-=.2;
		}

		//Fade white -> blue -> yellow -> red -> black
		else if(COLORSET==4)
		{
			if(r>20 && g>20 && b>30)
			{
				r-=.1;
				g-=.2;
			}

			else if(b>0)
			{
				b-=.1;
			}

			else
			{
				if(r>0)r-=.04;
				if(g>0)g-=.5;
			}
		}

		//As soon as particles disappear reset them
		if((int)r==0 && (int)g==0 && (int)b==0)Reset();
	}

	//Reset particles position and color
	void Reset()
	{
		x = SCREEN_WIDTH/2;
		y = SCREEN_HEIGHT/2;
		dirx = (rand() % 200) + xrandmod;
		diry = (rand() % 200) + yrandmod;
		if(COLORSET==1){r=31; g=63; b=31;}
		else if(COLORSET==2){r=rand()%255; g=rand()%255; b=rand()%255;}
		else if(COLORSET==3){r=31;g=0;b=0;}
		else if(COLORSET==4){r=31;g=63;b=31;}
	}

	//Erase the particle from the screen, but do not reset it
	void Erase(USHORT *buffer, int nPitch)
	{
		//Color = black;
		int color2 = RGB(0,0,0);

		//Draw black over all 4 pixels of current particle to erase it.
		buffer[(int)y*nPitch + (int)x] = color2;
		buffer[(int)(y+1)*nPitch + (int)x] = color2;
		buffer[(int)y*nPitch + (int)x+1] = color2;
		buffer[(int)(y+1)*nPitch + (int)x+1] = color2;
	}
};

main.cpp
Code:
#include <windows.h>
#include <windowsx.h>
#include <ddraw.h>
#include <stdlib.h>	
#include <time.h>
#include "myDD.h"
#include "Particle.h"

const int MAX_PARTICLES = 10000;

LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
void MyOutput(int,int,int,int,char*,HDC);
void WriteDigit(int,int,int,HDC);

int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprev, PSTR cmdline, int ishow)
{
	//All the necessary windows crap
    HWND hwnd;
    MSG msg;
    WNDCLASSEX wndclassex = {0};
	ghinstance=hinstance;
	bool window_closed = 0;
	Particle particles[MAX_PARTICLES];
	int numparticles = 1000;
	int frames = 0;
	//clock_t timer;

	wndclassex.cbSize = sizeof(WNDCLASSEX);
    wndclassex.style = CS_HREDRAW | CS_VREDRAW;
    wndclassex.lpfnWndProc = WinProc;
    wndclassex.hInstance = hinstance;
    wndclassex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wndclassex.lpszClassName = CLASS_NAME;

    RegisterClassEx(&wndclassex);
    hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, CLASS_NAME, "DD", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hinstance, NULL);
	ShowCursor(false);
   

	//Setup DirectDraw and its Primary and Backbuffer Surfaces
	DirectDrawCreateEx(NULL, (void **)&lpdd, IID_IDirectDraw7, NULL);
	lpdd->SetCooperativeLevel(hwnd, DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT);
	lpdd->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP,0,0);
	memset(&ddsd,0,sizeof(ddsd)); 
	ddsd.dwSize = sizeof(ddsd);
	ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
	ddsd.dwBackBufferCount = 1;
	ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_VIDEOMEMORY;
	lpdd->CreateSurface(&ddsd, &primarysurface, NULL);
	ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
	primarysurface->GetAttachedSurface(&ddsd.ddsCaps,&backsurface);

	//Attach the clipper to the backbuffer
	RECT screen_rect= {0,0,SCREEN_WIDTH,SCREEN_HEIGHT};
	lpddclipper = DDraw_Attach_Clipper(backsurface,1,&screen_rect);
	
	//Set up the background surface
	memset(&ddsd,0,sizeof(ddsd)); 
	ddsd.dwSize = sizeof(ddsd);
	ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
	ddsd.dwWidth = SCREEN_WIDTH;
	ddsd.dwHeight = SCREEN_HEIGHT;
	ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
	lpdd->CreateSurface(&ddsd, &level1, NULL);

	srand(time(0));
	memset(&ddsd, 0, sizeof(ddsd));
	ddsd.dwSize = sizeof(ddsd);
	USHORT* buffer = (USHORT*)ddsd.lpSurface;
	UINT nPitch = ddsd.lPitch >> 1;
	//HDC hDC;
	
	//Start initial timing
    //timer = clock() + CLK_TCK; //Set time to the current time plus one tenth of a second (CLK_TCK = Clock ticks per second)
	
	//Main program logic goes here
	while(1)
	{
		if(PeekMessage(&msg,hwnd,0,0,PM_REMOVE))
		{
			if(msg.message == WM_QUIT)break;
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		
		if(window_closed)return(0);
		
		//INPUT
		if(KEYDOWN(VK_INSERT))
		{
			if(numparticles<MAX_PARTICLES)
			{
				for(int i=numparticles;i<numparticles+10;i++)particles[i].Reset();
				numparticles+=10;
			}
		}
		if(KEYDOWN(VK_DELETE))
		{
			if(numparticles>10)
			{
				numparticles-=10;
				backsurface->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL);
				buffer = (USHORT*)ddsd.lpSurface;
				nPitch = ddsd.lPitch >> 1;
				for(int i=numparticles;i<numparticles+10;i++)particles[i].Erase(buffer,nPitch);
				backsurface->Unlock(NULL);

			}
		}
		if(KEYDOWN(VK_ADD))if(speed>1)speed-=.5;
		if(KEYDOWN(VK_SUBTRACT))speed+=.5;
		if(KEYDOWN(VK_UP))yrandmod-=2;
		if(KEYDOWN(VK_DOWN))yrandmod+=2;
		if(KEYDOWN(VK_LEFT))xrandmod-=2;
		if(KEYDOWN(VK_RIGHT))xrandmod+=2;
		if(KEYDOWN(VK_RETURN))while(!KEYUP(VK_RETURN));
		if(KEYDOWN(VK_SPACE))Sleep(100);
		if(KEYDOWN(VK_LBUTTON))GRAVITY++;
		if(KEYDOWN(VK_RBUTTON))GRAVITY--;
		if(KEYDOWN(VK_MBUTTON))GRAVITY=0;
		if(KEYDOWN(VK_LSHIFT)){COLORSET++; if(COLORSET==5)COLORSET=1;do{}while KEYDOWN(VK_LSHIFT);}

		/*
		backsurface->GetDC(&hDC);
		
		if(clock() >= timer)
		{
			MyOutput(frames,10,10,3,"fps",hDC);
			frames = 0;					//reset frame counter
			timer = clock() + CLK_TCK;	//reset time counter
		}
		
		backsurface->ReleaseDC(NULL);
		*/
		
		
		backsurface->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL);
		
		buffer = (USHORT*)ddsd.lpSurface;
		nPitch = ddsd.lPitch >> 1;

		for(int i=0;i<numparticles;i++)	particles[i].Move(buffer, nPitch);
		
		backsurface->Unlock(NULL);

		//frames++;

		//Flip buffers
		primarysurface->Blt(NULL,backsurface,NULL,DDBLT_WAIT,NULL);
	}

	UnregisterClass(CLASS_NAME,hinstance);
	return msg.wParam;
}


LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
	PAINTSTRUCT ps;
	
    switch(message)
    {
 		case WM_PAINT:
           	BeginPaint(hwnd,&ps);
			EndPaint(hwnd,&ps);
			return 0;

		case WM_KEYDOWN:
			//if(GetAsyncKeyState(VK_ESCAPE)) PostQuitMessage(0);
			switch(wparam)
			{
				case VK_ESCAPE: PostQuitMessage(0); break;

			}
			return 0;

		case 0x020A://WM_MOUSEWHEEL, because VC++ 6 is stupid and doesn't define it.
			if((short)HIWORD(wparam) > 0)GRAVITY+=2;
			else GRAVITY-=2;
			return 0;

        case WM_DESTROY:
		case WM_CLOSE:
			PostQuitMessage(0);
            return 0;
	}

    return DefWindowProc(hwnd, message, wparam, lparam);
}

void MyOutput(int number, int x, int y, int numchars, char* endtext, HDC hDC)
{
	SetBkColor(hDC,RGB(0,0,0));
	//SetBkMode(hDC,TRANSPARENT);
	SetTextColor(hDC,RGB(255,255,255));

	TextOut(hDC,x,y,"                    ",20);
	
	int onesdigit;
	int tensdigit;
	int hundredsdigit;
	
	if(number>=100 && number<1000)
	{
		hundredsdigit=number/100;
		if(hundredsdigit==9)number-=900;
		if(hundredsdigit==8)number-=800;
		if(hundredsdigit==7)number-=700;
		if(hundredsdigit==6)number-=600;
		if(hundredsdigit==5)number-=500;
		if(hundredsdigit==4)number-=400;
		if(hundredsdigit==3)number-=300;
		if(hundredsdigit==2)number-=200;
		if(hundredsdigit==1)number-=100;
		tensdigit=number/10;
		if(tensdigit==9)onesdigit=number-90;
		if(tensdigit==8)onesdigit=number-80;
		if(tensdigit==7)onesdigit=number-70;
		if(tensdigit==6)onesdigit=number-60;
		if(tensdigit==5)onesdigit=number-50;
		if(tensdigit==4)onesdigit=number-40;
		if(tensdigit==3)onesdigit=number-30;
		if(tensdigit==2)onesdigit=number-20;
		if(tensdigit==1)onesdigit=number-10;
		if(tensdigit==0)onesdigit=number-0;
		WriteDigit(hundredsdigit,x,y,hDC);
		WriteDigit(tensdigit,x+10,y,hDC);
		WriteDigit(onesdigit,x+20,y,hDC);
		TextOut(hDC,x+30,y,endtext,numchars);
		
	}

	else if(number>=10 && number<100)
	{
		tensdigit=number/10;
		if(tensdigit==9)onesdigit=number-90;
		if(tensdigit==8)onesdigit=number-80;
		if(tensdigit==7)onesdigit=number-70;
		if(tensdigit==6)onesdigit=number-60;
		if(tensdigit==5)onesdigit=number-50;
		if(tensdigit==4)onesdigit=number-40;
		if(tensdigit==3)onesdigit=number-30;
		if(tensdigit==2)onesdigit=number-20;
		if(tensdigit==1)onesdigit=number-10;
		WriteDigit(tensdigit,x,y,hDC);
		WriteDigit(onesdigit,x+10,y,hDC);
		TextOut(hDC,x+20,y,endtext,numchars);
	}
	
	else if(number<10) WriteDigit(number,10,10,hDC);

	
}

void WriteDigit(int digit, int x, int y, HDC hDC)
{
	if(digit==0)TextOut(hDC,x,y,"0",1);
	else if(digit==1)TextOut(hDC,x,y,"1",1);
	else if(digit==2)TextOut(hDC,x,y,"2",1);
	else if(digit==3)TextOut(hDC,x,y,"3",1);
	else if(digit==4)TextOut(hDC,x,y,"4",1);
	else if(digit==5)TextOut(hDC,x,y,"5",1);
	else if(digit==6)TextOut(hDC,x,y,"6",1);
	else if(digit==7)TextOut(hDC,x,y,"7",1);
	else if(digit==8)TextOut(hDC,x,y,"8",1);
	else if(digit==9)TextOut(hDC,x,y,"9",1);
}
 
buzzard34 said:
it works cuz I have a pc. thats really cool, I really couldn't make something like that cause I would get fustrated and give up...still going with EENG btw. How do you quit that progam, had to use taskmgr.

esc key quits, sometimes you have to hold it for a half second or so, don't know why.

Electrical Engineering is good too. If you enjoy it more then go for it. More money in CS though and I like it...
 
I've been working on Pacman too, I don't have much free time though with work and school so it has kind of stalled lol. Pacman
 
CHollman82 said:
esc key quits, sometimes you have to hold it for a half second or so, don't know why.

Electrical Engineering is good too. If you enjoy it more then go for it. More money in CS though and I like it...
yeah i like computers and want to know everything about them on a hardware level but don't give a shit about software. getting a CE dgree at my school entails a few programming classes, so i'm kinda stuck.:( btw the code looks horrendous, did you write that from scratch? i can't figure out any of it.
 
buzzard34 said:
yeah i like computers and want to know everything about them on a hardware level but don't give a shit about software. getting a CE dgree at my school entails a few programming classes, so i'm kinda stuck.:( btw the code looks horrendous, did you write that from scratch? i can't figure out any of it.
Stick with hardware and electronics then. Yeah, I wrote all that myself, but a lot of it has to do with initializing and using DirectDraw, which is why you wouldn't recognize it.
 
man im in computer engineering at the local community college. its hard. dc/ac circuits is not easy. i know what ya mean. im facing a visual basic programming class (and i don't know anything about vb). im thinking of switching my major to networking tech.
 
f U z ! o N said:
man im in computer engineering at the local community college. its hard. dc/ac circuits is not easy. i know what ya mean. im facing a visual basic programming class (and i don't know anything about vb). im thinking of switching my major to networking tech.
i'd have taken that class (took Network+ and CCNA in high school) but my school didn't offer it. :(
 
buzzard34 said:
i'd have taken that class (took Network+ and CCNA in high school) but my school didn't offer it. :(

How long does Cisco certification last? I got my CCNA cert in highschool too but if it expires it probably has by know.
 
CHollman82 said:
How long does Cisco certification last? I got my CCNA cert in highschool too but if it expires it probably has by know.
like 2 years i think. I didn't get certified, but i took the class anyway
 
fluxion said:
i had way too much fun with that haha. cool stuff

If you like that you should see my new version... I've made it so they will bounce off the walls and ceilings and added several color schemes where the particles will fade between colors. I have one for smoke and one for fire where they start out white, then blue, then yellow, orange, red, and finally black and are reset, it makes a pretty cool flame effect but I'm still working on it...
 
Back
Top