Click here to Skip to main content
15,897,891 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to creat exe files? Pin
gamitech17-Nov-04 10:35
gamitech17-Nov-04 10:35 
GeneralRe: How to creat exe files? Pin
Dody_DK17-Nov-04 10:53
Dody_DK17-Nov-04 10:53 
GeneralRe: How to creat exe files? Pin
gamitech17-Nov-04 10:56
gamitech17-Nov-04 10:56 
GeneralRunning main() from a dialog-based control Pin
aaadetos13-Nov-04 9:30
aaadetos13-Nov-04 9:30 
GeneralRe: Running main() from a dialog-based control Pin
aaadetos13-Nov-04 12:55
aaadetos13-Nov-04 12:55 
GeneralRe: Running main() from a dialog-based control Pin
John R. Shaw13-Nov-04 16:58
John R. Shaw13-Nov-04 16:58 
GeneralRe: Running main() from a dialog-based control Pin
aaadetos14-Nov-04 16:16
aaadetos14-Nov-04 16:16 
GeneralRe: Running main() from a dialog-based control Pin
John R. Shaw17-Nov-04 7:39
John R. Shaw17-Nov-04 7:39 
void CKuchukDlg::OnAnalyze() 
{ 
    // let maximum number of layers = 100: this value can be modified.
	// ???
	// THIS VALUE IS UNKNOWN : NOT INITIALIZE (YOUR PROGRAM IS GOING TO CRASH!)
	// SHOULD BE int num_layers = 100;
	// SINCE YOU HARD CODED THE VALUE OF 100 INTO ALL YOUR ARRAYS, YOU CAN
	// ONLY INITIALIZE TO 100 OR LESS.
	// ???
    int num_layers;
	
    // ???
	// THE FOLLOWING IS AN INSTANCE OF A NEW CKuchuncDlg OBJECT VARIABLE
	// NAMED MyClass. THAT YOUR ARE NOT USING AND DOES NOT BELONG HERE
	// ???
	CKuchukDlg MyClass; // instance of object MyClass of class CKuchukDlg
    MyClass.m_iLayers = num_layers;
	
    // ???
	// THE INDEX GOES FROM 0 - 99: NOT 1 - 100
	// THIS IS C++ NOT VISUAL BASIC!
	// YOUR PROGRAM IS GOING TO CRASH!
	// ???
	int i = 1; // index to count what line is being read: start at line 1;
    int H_ft[100],kh_md[100], kv_md[100];
    float visc_cp[100], por[100], ct_psi[100];
	
    char line[100];
	
	
    ifstream inputdeck;
    inputdeck.open("input.txt", ios::in);
	
    if (inputdeck.fail())
    {
        //cout<<"Error With Files!";
        AfxMessageBox("File Read Error!", MB_ICONSTOP);
    }
    else
    {
		// ???
		// I THOUGHT YOU WANTED TO READ FROM A FILE VIA inputdeck!
		// THIS READ UPTO 60 CHARACTER FROM STANDARD INPUT (KEYBOARD) 2 TIMES!
		// BASICALY THIS SHOULD FLUSH ANY CHARACTERS THAT MIGHT BE WAITING
		// IN THE STANDARD INPUT BUFFER.
		// ???
		// IT LOOKS LIKE YOU WANT TO READ AND IGNORE THE FIRST 2 LINES OF
		// CHARACTERS FROM THE iputdeck STREAM.
		// ???
		cin.ignore(60, '\n');
		cin.ignore(60, '\n');
		
		// ???
		// while( i <= KNOWN VALUE && I CAN READ AND IGNORE 100 CHARACTERS FOME THE KEYBOARD )
		// {    READ IN SOME NUMERIC VALUES FROM KEYBOARD; }
		// ???
		while (i <= num_layers && cin.getline(line,100)) // 
		{
			// ?? WHEN i = 100 (YOUR PROGRAM IS GOING TO CRASH!)
			cin>>H_ft[i]>>kh_md[i]>>kv_md[i]>>visc_cp[i]>>por[i]>>ct_psi[i];
			i++;
			
		} /* while block */
	}
	
	
	ofstream outputdeck;
	outputdeck.open("output.txt", ios::out);
	
	outputdeck<<"Pressure\n";
	
	extern double pressure(double x); // ??? UNUSED EXTERNAL FUNCTION DECLARATION ???
	extern double press; // ??? UNKOWN EXTERNAL GLOBAL VARIABLE ???
	
	outputdeck<<press<<endl;
	
}


In general this code makes no since!
1) You are using unitialize variable, which should cause the compilire generate errors (or crash the program).
2) You open of file for reading and read nothing from it.
3) You declare a global external funciton and then do not call it.

I hate to say this but, you need to do a lot more studying (or find a local tutor) before writing any more code like this.

INTP
GeneralRe: Running main() from a dialog-based control Pin
aaadetos19-Nov-04 21:39
aaadetos19-Nov-04 21:39 
GeneralRe: Running main() from a dialog-based control Pin
John R. Shaw20-Nov-04 11:03
John R. Shaw20-Nov-04 11:03 
GeneralCEdit subclass question Pin
nguyenvhn13-Nov-04 6:48
nguyenvhn13-Nov-04 6:48 
GeneralRe: CEdit subclass question Pin
BlackDice13-Nov-04 11:39
BlackDice13-Nov-04 11:39 
GeneralRe: CEdit subclass question Pin
nguyenvhn13-Nov-04 14:46
nguyenvhn13-Nov-04 14:46 
GeneralRe: CEdit subclass question Pin
John R. Shaw13-Nov-04 17:29
John R. Shaw13-Nov-04 17:29 
GeneralRe: CEdit subclass question Pin
Ravi Bhavnani13-Nov-04 23:21
professionalRavi Bhavnani13-Nov-04 23:21 
GeneralCAsyncSocket Question Pin
Rassul Yunussov13-Nov-04 0:01
Rassul Yunussov13-Nov-04 0:01 
Generaltime critical thread Pin
LeeeNN12-Nov-04 20:17
LeeeNN12-Nov-04 20:17 
GeneralRe: time critical thread Pin
Michael Dunn13-Nov-04 5:39
sitebuilderMichael Dunn13-Nov-04 5:39 
GeneralRe: time critical thread Pin
Anonymous13-Nov-04 9:57
Anonymous13-Nov-04 9:57 
GeneralRe: time critical thread Pin
John R. Shaw13-Nov-04 17:49
John R. Shaw13-Nov-04 17:49 
GeneralPostThreadMessage Pin
includeh1012-Nov-04 19:17
includeh1012-Nov-04 19:17 
GeneralRe: PostThreadMessage Pin
peterchen12-Nov-04 19:50
peterchen12-Nov-04 19:50 
Questionemail ? Pin
BaldwinMartin12-Nov-04 18:25
BaldwinMartin12-Nov-04 18:25 
GeneralCTreeCtrl item display limit or multiline Pin
Pakosan12-Nov-04 18:02
Pakosan12-Nov-04 18:02 
GeneralHelp :: can't include afximpl.h in VC++.NET Pin
TooLeeDiN12-Nov-04 17:19
TooLeeDiN12-Nov-04 17:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.