problem if statement

This is a discussion on problem if statement within the C++ Programming forums, part of the General Programming Boards category; When I insert the below code into my program, I get a core. Can somebody maybe point out any obvious ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    11

    problem if statement

    When I insert the below code into my program, I get a core. Can somebody maybe point out any obvious problems? Thanks in advance:

    code
    -----------------------------------------------------------
    if(mfileInfo.GetName().data() != NULL) {
    if(mfileInfo.GetName() == *(mfileList_m[index]->getName())) {
    return(mfileList_m[index]->openMfile(mfileInfo);
    }
    else {
    continue; //this group of if's is in a for loop.
    }
    }
    ------------------------------------------------------------

    mfileInfo.GetName().data() returns a char*, so is it legal to do a (char* != NULL)? I have a feeling that it is that line that is hosing me up.

    And just so you have more info: mfileInfo.GetName() is a CSIString whereas mfileList[index]->getName() is a CSIString*

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,493
    Your char* might be initialized to god knows where. A NULL check could not prevent that. Without more code, we can't know.

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    If you are trying to compare 2 char[] use strcmp(). Could be almost anything.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Switch statement problem
    By jalex39 in forum C Programming
    Replies: 6
    Last Post: 03-08-2008, 04:05 PM
  2. having problem with string statement during a loop!
    By Hp7130p in forum C++ Programming
    Replies: 5
    Last Post: 04-21-2005, 10:40 AM
  3. If statement re-do problem
    By RoD in forum Windows Programming
    Replies: 5
    Last Post: 09-11-2002, 05:46 PM
  4. Major Problem
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 02-19-2002, 01:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21