Error with Struct Def.
I seem to be haveing a bit of trouble here... in MSVC++ ... i am sometimes not able to access my arrays... and when i have a problem it says that the value of esp was not retianed across a funciton call.. but i didn''t call a function... i simply accessed an array ... and it is all c (no assembly)...
here is the code
Product * OpenRig; // global. initialized elsewhere
char String[MAX_COLOR_CHARS + 2];
SendDlgItemMessage(hDlg, (combo box ID), WM_GETTEXT, MAX_COLOR_CHARS, (LPARAM) String); // this works
OpenRig->ContainerColors[0][0] = String[0]; // here i get the error
if i comment out that line, it all works.. i tried that line in another function and it worked! but still not in the function i need it...! uggghh..
in case it matters it is called from my dialog procedure which is _stdcall.
other definitions
#define MAX_COLOR_CHARS 16
typedef struct Product_Tag{
int SerialNumber; // Works fine
int Size; // Wors fine
// other stuff all working fine cut out for the post
char BodyContactColor[MAX_COLOR_CHARS]; // Doesn''t work
char ContainerColors[8][MAX_COLOR_CHARS]; // doesn''t work
char CenterFlapStripesColors[7][MAX_COLOR_CHARS]; // doesn''t work either..
}Product;
i have no idea what is wrong... it any one could help, please do
Thanx
RanXacT
RanXact@yahoo.com
Not having your code, I''m assuming you are declaring String inside a function that is different from where OpenRig was declared.
When you declare a variable inside a function, that variable is not accessible outside the scope of the function in which it is declared. So, when you are setting OpenRig->ContainerColors = String[0], you are setting it equal to a pointer to a variable(String[0] == &String) that will not exist outside the function. What I think you really want is a copy of the string, in which case you will need to use strcpy().
Mark Fassett
Laughing Dragon Entertainment
http://www.laughing-dragon.com
When you declare a variable inside a function, that variable is not accessible outside the scope of the function in which it is declared. So, when you are setting OpenRig->ContainerColors = String[0], you are setting it equal to a pointer to a variable(String[0] == &String) that will not exist outside the function. What I think you really want is a copy of the string, in which case you will need to use strcpy().
Mark Fassett
Laughing Dragon Entertainment
http://www.laughing-dragon.com
now, actually i was originally using strcpy(), but when that gave me an error i started trying to see what the problem was... in actuallity accessing the arrays at all gives me the error (esp not retianed over a function call)... so it has nothing to do with the string variable...
here is the exact code
long _stdcall EditProductColorsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
char String[MAX_COLOR_CHARS + 2];
switch (message)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
// check validity
int temp;
temp = SendDlgItemMessage(hDlg, IDC_PRODUCT_COLORS_1, WM_GETTEXT, MAX_COLOR_CHARS, (LPARAM) String);
OpenRig->ContainerColors[0][0] = '5'; // error
}
// rest ommitted...
ThanX
RanXacT
Edited by - RanXacT on June 21, 2000 1:53:38 PM
RanXact@yahoo.com
I can''t say for sure but I think what you are doing is:
When you are accessing the the structure is it from another file?
If so you need to include the definition of the structure as well as the extern definition of OpenRig
Just a guess.
When you are accessing the the structure is it from another file?
If so you need to include the definition of the structure as well as the extern definition of OpenRig
Just a guess.
D.V.Carpe Diem
It would also help if you would provide us with the definition of your OpenRig structure as well. How is ContainerColors defined?
Mark Fassett
Laughing Dragon Entertainment
http://www.laughing-dragon.com
Mark Fassett
Laughing Dragon Entertainment
http://www.laughing-dragon.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement