Difference between a string and an array

Ask a question
          

String and array


<<Previous   Next>>
C - difference between a string and an array - Jan 11, 2010 at 17:20 PM by Vidya sagar

What is the difference between a string and an array?

The following are the differences:

- String can hold only char data. Where as an array can hold any data type.
- An array size can not be changed. Where as a string size can be changed if it is a char pointer
- The last element of an array is an element of the specific type. The last character of a string is a null – ‘\0’ character.
- The length of an array is to specified in [] at the time of declaration (except char[]). The length of the string is the number of characters + one (null character).     

<<Previous   Next>>



Write your comment - Share Knowledge and Experience


 
Latest placement tests
Latest links
 
 
Home | Login | About us | Sitemap | Contact us