im trying to check if a string is null ( has nothing in it)
this is what i did:
char *str[]={0};
do {
STUFF
} while (str != NULL);
im trying to check if a string is null ( has nothing in it)
this is what i did:
char *str[]={0};
do {
STUFF
} while (str != NULL);
if (str == "")
{
printf("The string is null!");
}
I think this would b the most effective way of doing it.
char *str;
if (str == NULL){
do_stuff();
printf("the string is null");
}
//mah-gnu-s
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 :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi