Click here to Skip to main content
16,006,475 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: HELP! VC++/ADO connect & open .mdb problem Pin
Toni7822-Jul-03 8:47
Toni7822-Jul-03 8:47 
GeneralRe: We can not use upload/download Pin
ATC22-Jul-03 11:02
ATC22-Jul-03 11:02 
GeneralRe: We can not use upload/download Pin
Toni7822-Jul-03 11:17
Toni7822-Jul-03 11:17 
GeneralRe: HELP! VC++/ADO connect & open .mdb problem Pin
Alexander M.,22-Jul-03 9:33
Alexander M.,22-Jul-03 9:33 
GeneralRe: Is there anyway to access directly? Pin
ATC22-Jul-03 11:03
ATC22-Jul-03 11:03 
GeneralRe: Is there anyway to access directly? Pin
Alexander M.,23-Jul-03 2:11
Alexander M.,23-Jul-03 2:11 
GeneralRe: Is there anyway to access directly? Pin
Terry O'Nolley24-Jul-03 3:09
Terry O'Nolley24-Jul-03 3:09 
QuestionArray definition global vs local? Pin
spaced_out22-Jul-03 6:27
spaced_out22-Jul-03 6:27 
I can define an array in my local variables (to a certain function), but I am having trouble defining that array as a global array that I could use in all of my subfunctions.

Here is how I define the variable in my local area (this works)

<br />
//***********THIS WORKS AND IS WAHT I HAVE****************  it is in my .cpp source file<br />
void CMyDialog::OnMyFuntion() //my local function(subroutine? I don't know the right word?)<br />
{<br />
<br />
    double f1, m_div;  //defining a itermediate variable - I will remove this later when array is fully funtional<br />
    double ValuesArray[200]; // local definition of Array<br />
	<br />
	ifstream inf;                  <br />
	inf.open("Testdata1tab.txt");   //reading data in from text file<br />
<br />
	for (int i=0; i < 199; i++)    // loop 200 times for 200 lines of data<br />
	{<br />
		inf >> f1;             // read value into my temp variable f1<br />
		ValuesArray[i] = f1;   // transfer to array value at location [i]<br />
<br />
		Value = ValuesArray[i]/m_div;  //calculate another value<br />
	}<br />
<br />
    inf.close();<br />
	}<br />
}<br />


When I try to define the array in my .h file as a public variable, I get a runtime error. Here is how I try to define the array:

<br />
//************THIS DOES NOT WORK *************** PLEASE HELP<br />
class CMyDialog : public CDialog<br />
{<br />
// Construction<br />
public:<br />
	CMyDialog(CWnd* pParent = NULL);   // standard constructor<br />
// Dialog Data<br />
	//{{AFX_DATA(CMyDialog)<br />
	enum { IDD = IDD_MY_DIALOG };<br />
	double ValuesArray[200];<br />
		// NOTE: the ClassWizard will add data members here<br />
	//}}AFX_DATA<br />

I leave the .cpp file at the top the same, except that I remove the double ValuesArray[200]; line.
I am probaly doing several things wrong. Any help will be more than welcome.


I wish I could type better ...
AnswerRe: Array definition global vs local? Pin
John M. Drescher22-Jul-03 6:36
John M. Drescher22-Jul-03 6:36 
GeneralRe: Array definition global vs local? Pin
spaced_out22-Jul-03 8:49
spaced_out22-Jul-03 8:49 
GeneralRe: Array definition global vs local? Pin
John M. Drescher22-Jul-03 8:53
John M. Drescher22-Jul-03 8:53 
GeneralRe: Array definition global vs local? Pin
spaced_out22-Jul-03 17:37
spaced_out22-Jul-03 17:37 
AnswerRe: Array definition global vs local? Pin
Michael P Butler22-Jul-03 6:48
Michael P Butler22-Jul-03 6:48 
GeneralRe: Array definition global vs local? Pin
spaced_out22-Jul-03 17:44
spaced_out22-Jul-03 17:44 
AnswerRe: Array definition global vs local? Pin
David Crow22-Jul-03 9:02
David Crow22-Jul-03 9:02 
GeneralRe: Array definition global vs local? Pin
spaced_out22-Jul-03 17:50
spaced_out22-Jul-03 17:50 
AnswerRe: Array definition global vs local? Pin
Alexander M.,22-Jul-03 9:14
Alexander M.,22-Jul-03 9:14 
GeneralRe: Array definition global vs local? Pin
John M. Drescher22-Jul-03 10:30
John M. Drescher22-Jul-03 10:30 
GeneralRe: Array definition global vs local? Pin
spaced_out22-Jul-03 18:06
spaced_out22-Jul-03 18:06 
GeneralRe: Array definition global vs local? Pin
John M. Drescher22-Jul-03 18:39
John M. Drescher22-Jul-03 18:39 
GeneralRe: Array definition global vs local? Pin
Alexander M.,23-Jul-03 1:30
Alexander M.,23-Jul-03 1:30 
GeneralRe: Array definition global vs local? Pin
John M. Drescher23-Jul-03 3:44
John M. Drescher23-Jul-03 3:44 
GeneralProblem Solved!! Pin
spaced_out22-Jul-03 18:05
spaced_out22-Jul-03 18:05 
GeneralRe: Problem Solved!! Pin
John M. Drescher22-Jul-03 18:36
John M. Drescher22-Jul-03 18:36 
GeneralRe: Problem Solved!! Pin
David Crow23-Jul-03 2:23
David Crow23-Jul-03 2:23 

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.