Home > Back-end >  Interrupt a printf, runtime
Interrupt a printf, runtime

Time:09-17

I'm watching others written source code, because reading difficulties, want to have a look at the data structure of the concrete data, keeping the concept, but in the output when encounter problems,

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:

Eldest brother, you is how to define the HMM, define a pointer have allocated space, the vector you don't to push_back data, the default is no data, print error, of course,

CodePudding user response:

HMM is a structure pointer, myf=(HMM - & gt; Dur) [0] ok, this sentence if is empty, I think this sentence is an error, but if this sentence, printf that sentence was added to operation error, I do think, since myf can be assignment, no matter how to have a value, and is a float variable myf, don't know why to myf printf is not

CodePudding user response:

1/f, said makes sense, should be (HMM - & gt; Dur) [0] this data has a problem, can debug and see whether there is data in the dur

CodePudding user response:

refer to the second floor qq_40252810 response:
HMM is a structure pointer, myf=(HMM - & gt; Dur) [0] ok, this sentence if is empty, I think this sentence is an error, but if this sentence, printf that sentence was added to operation error, I do think, since myf can be assignment, no matter how to have a value, and is a float variable myf, don't know why to myf printf is no

Stick a complete code

CodePudding user response:

Checked, this really is empty, but I read yesterday is determine whether is NULL, the error is 0 x00000005 yesterday, a small address, how can this let I to judge?

CodePudding user response:

I find much of this, is to read cannot read space, the value of the pointer is NULL, the NULL is 0, but yesterday before I read other pointer does determine whether is NULL, the error is 0 x00000005 yesterday, the address also cannot read, if I can judge whether the pointer is NULL, so little value I how can you read?