I write the part of source program code:
Typedef struct {
.
SVector dur;
.
} HMMDef;
Typedef Vector SVector;
Typedef float * Vector;//vector [1... size]
HMMDef * HMM;
HMM=node - & gt; Info. HMM;
Above is part of source program code, I have run all the source code, no problem, I want to see the HMM structure dur in specific values, look at the shape of the described the dur should be a float array,
The following is my own code
Float myf=0.0;
.
Myf=(HMM - & gt; Dur) [0];
Printf (" % f ", myf);
.
Above is my code, if you have myf=(HMM - & gt; Dur) [0]; No printf (" % f ", myf); Compile and run fine
If there is no myf=(HMM - & gt; Dur) [0]; But have a printf (" % f ", myf); Compile and run the no problem, can output 0.0
But if, both myf=(HMM - & gt; Dur) [0]; Next is the printf (" % f ", myf); Compiled through, but the runtime will interrupt, interrupt the tip is:
Unhandled exception at 0 x00418772 in HVite. Exe: 0 xc0000005: Access violation reading location 0 x00000000
Yesterday I encountered a similar problem, is to want to look at other data structures, it is the same problem, with not a printf, I thought I have a question for yesterday's structure understanding, today in a variable observation, or not, but for the structure of some variables can be output, but many can't printf variable, like this, really big, don't know what problem, is the source code where there is set up, don't let the reader read some data, C language can do this set? Some who do not understand, do to help, thank you
CodePudding user response:
Access violation because of Access to a piece of invalid memoryEither access memory has released
Or use a haven't create the object pointer
Remember to initialize the pointer, also remember to delete the rear pointer to NULL
CodePudding user response:
This pointer is NULL, is more or less error reading the NULL pointer value, but why myf=(HMM - & gt; Dur) [0] this is not an error?CodePudding user response:
Dur should be a pointer to a pointer to initialize, array defined distribution after the well space, can direct assignment,CodePudding user response:
This is a null pointer, but the day before yesterday I did judgment while reading other pointer is null, the error is 0 x00000005 the day before yesterday, so small address let me how to judge? It's not empty