Sunday , December 11 2016
Home / Blue J / How to Null a string or empty a string array

How to Null a string or empty a string array

Null a String/ Empty a string array
Null a string in C using pointer string or array string. Many times the string is nullified assigning arr[0]=’\0′ but this will not nullify the array as only the first index will be NULL.

 

1. Null a string using pointer string.
 

TO show that array/pointer is not actually empty or null the first array null but the rest of array characters are still on the same address.

ptr=””;                                  
printf(“%s and %s”, ptr,ptr+1);

OUTPUT:

hello
  and ello


2. Null a string using array string

Null a string using an array is not efficient as though the first index is nullified but the rest of the characters still have the same address.

 


OUTPUT:

null string= and l

 
Also See:   Program for Shortest Job First (SJF) scheduling technique

Check Also

Hide Mouse Pointer C Program

How to Hide a Mouse Pointer Program in C : This program will show and hide ...

Leave a Reply

Your email address will not be published. Required fields are marked *

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.