Hello everyone, with this sipmle program it puts out the right output, but i get an illegal operation when i type in 0, then i convert 0 to feherinheite, it prints out the rgiht result(32) but it says an illegal operation has occured here is teh illegal operation:
Code:
CONVERTER caused an invalid page fault in
module CONVERTER.EXE at 0187:0042684c.
Registers:
EAX=00000000 CS=0187 EIP=0042684c EFLGS=00010206
EBX=005b0000 SS=018f ESP=006bfe0c EBP=40400000
ECX=006bfe28 DS=018f ESI=8829fcc4 FS=9d2f
EDX=0047b804 ES=018f EDI=00000000 GS=0000
Bytes at CS:EIP:
89 45 e4 8b 55 e4 52 e8 78 fd ff ff 8b 45 ec 8b 
Stack dump:
00000000 8829fcc4 005b0000 c0000005 006bff68 006bfe0c 006bfc3c 006bff68 0043069c 004711d0 00000000 006bff78 bff8b560 00000000 8829fcc4 005b0000
here is my code:
Code:
#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
	const int MAX = 40;
	double fah[MAX];
	double cel[MAX];
	char buff[MAX];
	int choice;
	double degree;

	cout <<"Enter a number: \n";
	cin.get(buff,MAX); cin.ignore(200,'\n');

	if(strcmp(buff,"end") == 0)
	{
		cout <<"Thank you for using the program.";
	}
	else
	{
		degree = atof(buff);
		
		cout <<"(1) to convert celsius to fahrenheit\n";
		cout <<"(2) to convert fahrenheit to celsius" << endl;
		
		cin >> choice;

		switch(choice)
		{
		case 1: fah[MAX] = (((degree + 40) * 1.8) - 40);
			cout << fah[MAX] << endl;
			break;
		case 2: cel[MAX] = ((degree -32) / 1.8);
			cout << cel[MAX] << endl;
			break;
		default: cout <<"error occured.\n";
			break;
		}
	
		cout <<"thank you for using this application\n";
	}

	return 0;
}

thanks for listening