Thread: problem if statement

  1. #1
    Registered User
    Join Date
    May 2003

    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:

    if(mfileInfo.GetName().data() != NULL) {
    if(mfileInfo.GetName() == *(mfileList_m[index]->getName())) {
    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
    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
    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, 09:40 AM
  3. If statement re-do problem
    By RoD in forum Windows Programming
    Replies: 5
    Last Post: 09-11-2002, 04:46 PM
  4. Major Problem
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 02-19-2002, 01:06 PM