Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Difference between String and array

  1. #1
    puneet167
    Guest

    Post Difference between String and array

    An array is an array of anything. A string is a specific kind of an array
    with a well-known convention to determine its length.
    There are two kinds of programming languages: those in which a string
    is just an array of characters, and those in which it’s a special type. In
    C, a string is just an array of characters (type char), with one wrinkle: a
    C string always ends with a NUL character.
    The “value” of an array is the same as the address of (or a pointer to)
    the first element; so, frequently, a C string and a pointer to char are
    used to mean the same thing.
    An array can be any length. If it’s passed to a function, there’s no way
    the function can tell how long the array is supposed to be, unless some
    convention is used. The convention for strings is NUL termination; the
    last character is an ASCII NUL (‘’) character.

  2. #2

    Default

    An arrangement of pointers is that for eg if we accept arrangement of 10 int pointers ie int *a[10] then each element that which is stored in array are pointed by pointers. Here we will have ten pointers. In pointer to an array for eg int(*a)[10] here all the elements that is all the ten elements are pointed by a single pointer.

  3. #3
    New Member jantanik's Avatar
    Join Date
    Jul 2011
    Location
    London
    Posts
    12

    Default

    An array is usually made of any data arranged into evenly spaced addresses in memory. In the case of a string, the data is a char. So in essence, a string is an array of chars.


  4. #4

    Default

    String is a variable that can hold a single value. Array is a collection of a variable that can hold multiple values in same type of data type.

  5. #5

    Default

    A data item (or variable) is described as a "string" type when it contains some number of characters. Those characters can usually be anything in the system's accepted list of codes. Most systems use ASCII, so a string can include the letters a-z, A-Z, numbers 0-9, and special characters like [email protected]#$%^&*()_+-=[]\{}|:";'<>?,/. A string is treated as a single object, although most programming languages have methods to break strings apart (called sub-stringing). In the Perl language, strings are named $something.
    An array is a collection of individual data items, sort of like a list. Each element in an array can be referred to in a program by its position in the list. In the Perl language, an array would be named @SOMETHING. The first element in the array would be named $SOMETHING[0], the second $SOMETHING[1], and so on. Each element can be a string, or some other data type.
    Other data types would be intergers (positive or negative whole numbers), floating point (decimal numbers like 3.14159 or 2398.41; it can be more complicated than this, but that's another story), and a few more exotic types.

  6. #6
    New Member waeywake's Avatar
    Join Date
    Sep 2011
    Location
    huston
    Posts
    5

    Default

    Difference between string and array are: string can hold character data type but array can hold every data type.array size never change when string size can be change when its char pointer.

  7. #7

    Default

    A String in C is an array of characters. An array is just a sequence of similarly-typed elements that are stored in consecutive memory locations and can be accessed by using the array index.

  8. #8

    Default

    Arrays hold multiple values

  9. #9
    New Member panashmarshel's Avatar
    Join Date
    Jan 2012
    Location
    USA
    Posts
    5

    Default

    A string is a specific kind of array and array is one type of variable that can store more than one one value in a single name.
    String is just index of characters, it end with NULL character and array is the address of first character.
    Size of string can be changed but size of array can not be change.

  10. #10

    Default

    String can contain only char. When such an array can contain any type of data.The length of an array is specified in [] at the time of the declaration (except char []). The length of the string is the number of characters + a (null).

Similar Threads

  1. What's the Difference Between SEO and SEM
    By madisondowey in forum Internet Marketing
    Replies: 21
    Last Post: 30-12-11, 04:32 PM
  2. Difference between struts and JSF
    By johnsteveen in forum Open Source
    Replies: 3
    Last Post: 23-07-11, 02:44 PM
  3. Difference between VB and .Net?
    By techkriti in forum Programming
    Replies: 6
    Last Post: 17-02-11, 12:09 AM
  4. PHP - difference between GET and POST
    By anitha chowdary in forum PHP
    Replies: 12
    Last Post: 28-12-10, 04:24 PM
  5. Know the Difference....
    By manishanand in forum Stock Market
    Replies: 0
    Last Post: 31-08-10, 05:29 PM

Share this page with your friends

Share this page with your friends

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •