EmbLogic's Blog

why we should avoid single character as string???…

example : char a[]=”a”; this is possible but not efficient because we have other method to assign character const as shown below:

char c=’a’;

3 Responses to why we should avoid single character as string???…

  1. kamran says:

    Please explain the question with some details.

  2. John Mcarthur says:

    Every string in C is terminated with a nul character. Therefore for a single character it consumes 2 bytes of memory, 1 for ‘a’ character and 1 for nul character . This in turn is not efficient in terms of memory.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>