C Strings Basics

Introduction to Character Array :

In C Programming we don’t have Sting data type. In C we have to use different approach to store the string. We are creating array of character to creating string. Suppose we have to accept the name of the person then n characters are collected together and string or character array is created.

Some Points Regarding Character Array | String in C Programming :

  1. String in C is also called as Character Array
  2. 'C','4','L','E','A','R','N'
    
  3. String is enclosed within Double quotes
  4. "Pritesh" is a example of String
    
  5. Each Character Occupy 1 byte of Memory
  6. Size of "Pritesh" = Size of 'P' +
                      = Size of 'R' +
                      = Size of 'I' +
                      = Size of 'T' +
                      = Size of 'E' +
                      = Size of 'S' +
                      = Size of 'H';
    Size of "Pritesh" = 7 BYTES
    
  7. Each Character is stored in consecutive memory location
  8. Address of 'P' = 2000
    Address of 'R' = 2001
    Address of 'I' = 2002
    Address of 'T' = 2003
    Address of 'E' = 2004
    Address of 'S' = 2005
    Address of 'H' = 2006
    
  9. String always Terminated with NULL Character (‘/0′)
  10. char name[10] = {'P','R','I','T','E','S','H','\0'}
    
  11. NULL Character is having ASCII value 0
  12. ASCII Value of '\0' = 0
    
  13. As String is nothing but an array , so it is Possible to Access Individual Character
  14. name[10] = "Pritesh";
    

    It is possible to access individual character -

    name[0] = 'P';
    name[1] = 'r';
    name[2] = 'i';
    name[3] = 't';
    name[4] = 'e';
    name[5] = 's';
    name[6] = 'h';
    name[7] = '\0';