NULL - C string.h

C examples for string.h:NULL

Type

macro

From

<string.h> 

Description

This macro expands to a null pointer constant.

Demo Code


#include <stdio.h>
#include <string.h>

int main ()//from  www .j  av  a  2  s  .c  o m
{

  printf ("%d\n",NULL);

  return 0;
}

Demo Code

#include <stdio.h>
#include <string.h>

int main ()//ww  w.  j a  va 2 s .c  o m
{
  char str[] = "This is a sample string";
  char * pch;

  printf ("Looking for the 's' character in \"%s\"...\n",str);

  pch=strchr(str,'s');

  while (pch!=NULL)
  {
    printf ("found at %d\n",pch-str+1);
    pch=strchr(pch+1,'s');
  }
  return 0;
}

Related Tutorials