473,322 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Problem with converting older C struct to VS C 7.1

Hi,
I'm in trouble here... I need to get this program working to proceed with my application.

The program is very complex, it works fine on a 10 year old system written in IBM C/2. I am showing only what I think yu may need here, please let me know if you need anything else. I am converting it to VS 7.1 (C not C++). All my source is named .C.
No compile errors, but it throws an exception at runtime. Here is the structure and the code trying to write a pointer into it. (all defined as ptrs).
Just can't seem to get a handle on why it worked in the old environment but fails now.
Expand|Select|Wrap|Line Numbers
  1. // Struct
  2.  
  3. typedef struct line
  4. {
  5.     UCHAR *index,                      // pointer to product ( in valid.file )
  6.      lineNum,                          // line # of the family
  7.      famCount;                         // number of family members
  8.  
  9. }
  10. LINE;
  11.  
  12. typedef struct win
  13. {
  14.     UCHAR *firstRecord,                // first record in file
  15.      *lastRecord,                      // last record in file
  16.      *currentRecord;                   // pointer to current record
  17.  
  18.     LINE list[FAM_MAX + 1],            // product family info
  19.      *currentFamily,                   // pointer to current ( new ) family info
  20.      *lastFamily,                      // pointer to last ( previous ) family info
  21.      *defaultFamily,                   // default product family pointer
  22.      *prepriceFamily;                  // default preprice family pointer
  23.  
  24.     UCHAR *ppfirstRecord,              // first record in pre-price validation file
  25.      *pplastRecord,                    // last record in pre-price validation file
  26.      *ppcurrentRecord;                 // pointer to current record in validation file
  27.  
  28. }
  29. WINDOW;
  30.  
  31. // Code to write a pointer ( I verified it is a good pointer vale) to the struct.
  32.  
  33. window->currentFamily->index = filePtr;
  34.  
Thanks very much for any help you can provide. I am a fairly new C programmer.
Lee
Dec 24 '07 #1
2 1652
weaknessforcats
9,208 Expert Mod 8TB
window->currentFamily->index = filePtr;
If window is null or uninitialized -> Crash
If currentFamily is null or uninitialized -> Crash

index is the same type as filePtr?? Yes? Otherwise, the code probab;y won't compile.

Now you say an exception is thrown at run time. The code you show is not going to throw an exception. Bad pointers don't do that, they just crash the program.

How do you know you have an exception condtion?? Is this C?? C doesn't have exceptions. C++ does but this code coude be either C or C++.

Maybe you could post the error.
Dec 24 '07 #2
Thanks so very much for looking at this, it is a big problem for my customer..
OK, when I run this program the message I get is:
'etspt.exe has encountered a problem and needs to close, we are sorry for any inconveinience'

then I click debug and get:
'an exception 'unhandled win32 exception has occured in etspt.exe.

etspt.exe is the main code with this code I am having problems with running as a DLL.

As far as I can tell this struct does not get initialzed, it is all pointer oriented. Yes the type being assigned is a pointer too.
Also, If i change the code to:
window->currentRecord = filePtr;

it does not get an execution error.

This all works fine inthe existing older C program.


Thanks,
Lee
Dec 24 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: vertigo | last post by:
Hello I have: struct packet{ byte type; /*my byte is unsigned char*/ int len; } struct packet *p = new struct packet; p->type=10; p->len=0;
57
by: Xarky | last post by:
Hi, I am writing a linked list in the following way. struct list { struct list *next; char *mybuff; };
2
by: Lorenzo | last post by:
Hi I have a problem converting the follow union in c#: typedef union{ int iParam; char acParamChar; } Param; I tried with this but don't work... why?
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
4
by: Brett | last post by:
Hi, I'm having trouble converting an old project to visual studio C++ .net v7.1.3088 I've updated one of the header files to use #include <iostream>, and used the std namspace. After...
4
by: DeanL | last post by:
Hi All, Having a problem developing an Access 97 database in Access 2003. The database needs to go out to a number of staff who will review it and recommend any changes but when I convert the...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
1
by: DaTurk | last post by:
I'm having an issue converting an unmanaged struct to a CLI managed struct. It's a value struct and this cannot be changed. public value struct UpdateItem { public: System::String ...
4
by: screamer81 | last post by:
Hello, I've a SDK functions description for a scanner and I try to convert unmanaged DLL C++ functions to c#. I converted all except one of them. This function is getting a struct parameter. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.