Thread: question

  1. #1


    im trying to check if a string is null ( has nothing in it)

    this is what i did:

    char *str[]={0};

    do {
    } while (str != NULL);

  2. #2
    if (str == "")
    printf("The string is null!");

  3. #3
    I think this would b the most effective way of doing it.

    char *str;
    if (str == NULL){
    printf("the string is null");


  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    to compare strings use strcmp()

    alternatively a null string will have a length of 0 so strlen() will return 0.

    The previous example checks the pointer for null and not the string for 0 length.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :-

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM
Website Security Test