473,230 Members | 2,220 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,230 software developers and data experts.

Problem with converting older C struct to VS C 7.1

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
  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
  9. }
  10. LINE;
  12. typedef struct win
  13. {
  14.     UCHAR *firstRecord,                // first record in file
  15.      *lastRecord,                      // last record in file
  16.      *currentRecord;                   // pointer to current record
  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
  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
  28. }
  29. WINDOW;
  31. // Code to write a pointer ( I verified it is a good pointer vale) to the struct.
  33. window->currentFamily->index = filePtr;
Thanks very much for any help you can provide. I am a fairly new C programmer.
Dec 24 '07 #1
2 1650
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.

Dec 24 '07 #3

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

Similar topics

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;
by: Xarky | last post by:
Hi, I am writing a linked list in the following way. struct list { struct list *next; char *mybuff; };
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?
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....
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...
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...
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)...
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 ...
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. ...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.