• Advertisement

Archived

This topic is now archived and is closed to further replies.

Error with Struct Def.

This topic is 6456 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement