a null pointer Error

when i run my code i found a null pointer in the line following :
TFile * file = new TFile("ResultData18JUL.root", "READ");
TIter nextkey(gDirectory->GetListOfKeys());
TKey* key;
while (key == (TKey*)nextkey()){
if( !strcmp( key->GetName(), "OutputCent0_10")){
TList * V0Xi = (TList*)key->ReadObj();
could someone give a suggestion?
Thanks
Use a debugger see where the "null pointer error" is coming from.
I didn't have idea about the debugger How can i used
The debugger will be part of your IDE. The best way to learn to use it is to consult the documentation for your specific IDE.
One of the problems is certrainly this:

while (key == (TKey*)nextkey()){

Note that == compares the key. In this case you want it assigned (Note: single =).
it could be almost anything. you didnt check that your file opened correctly.
nextkey uses something we don't know what is.
key ==, key had no value (not initialized) and probably bug (agree with earlier post)
assumes key is valid and dereferences it in strcmp

Topic archived. No new replies allowed.