Thread: How to check if char* is empty or null??

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    38

    How to check if char* is empty or null??

    Ok - bit new to C - all I want to do is check if a char* is empty or null, in this case I'm checking *roadNumber. It keeps crashing when I run the code saying - "The instruction at blah de blah...The memory could not be read" - so I take it there is some conflict with two variables or something...
    If anyone can help that would be great.
    (BTW - the code is a conditional statement to transfer the contents from a char* to a char array, if roadNumber is empty do this bit of code, else do the other).

    Code:
    if (roadNumber = NULL)
    {
       for(i=0;i<length;i++)
       {
       oneRoadName[i] = propRoadName[i];
       }
    }
    else
    {
      for(i=0;i<length;i++)
      {
      oneRoadName[i] = roadNumber[i];
      }
    }
    Last edited by earnshaw; 12-14-2004 at 01:48 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help Debugging my AVL tree program.
    By Nextstopearth in forum C Programming
    Replies: 2
    Last Post: 04-04-2009, 01:48 AM
  2. New string functions
    By Elysia in forum C Programming
    Replies: 11
    Last Post: 03-28-2009, 05:03 AM
  3. Compiling 3rd party code problem me too
    By siavoshkc in forum C Programming
    Replies: 1
    Last Post: 09-12-2007, 05:55 AM
  4. Syntax Error??
    By Kennedy in forum C Programming
    Replies: 8
    Last Post: 09-06-2006, 11:04 AM
  5. Replies: 7
    Last Post: 06-16-2006, 09:23 PM