অনুরূপ অনেক Data একসাথে স্টোর করতে array এর ব্যবহার

Submitted by tushar pramanick on Mon, 01/02/2012 - 15:52

Storing Similar Data Items

In last Chapter you learned about pointers and the concept of indirection. In this lesson you'll learn about arrays, which are collections of similar data items and are closely related to pointers. The main topics covered in this lesson are

    Single-dimension arrays
    Indexing arrays
    Pointers and arrays
    Character arrays
    Multidimensional arrays
    Unsized arrays



Summary

In this lesson you've learned the following:

  •     An array is a collection of variables that are of the same data type.
  •     In C, the index to an array starts at 0.
  •     You can initialize each individual element of an array after the declaration of the array, or you can place all initial values into a data block surrounded by { and } during the declaration of an array.
  •     The memory storage taken by an array is determined by the product of the size of the data type and the dimensions of the array.
  •     A pointer is said to refer to an array when the address of the first element in the array is assigned to the pointer. The address of the first element in an array is also called the start address of the array.
  •     To assign the start address of an array to a pointer, you can either put the combination of the address-of operator (&) and the first element name of the array, or simply use the array name, on the right side of an assignment operator (=).
  •     A character array is considered a character string in C if the last element in the array contains a null character (\0).
  •     The null character (\0) marks the end of a string. C functions, such as printf(), will stop processing the string when the null character is encountered.
  •     C supports multidimensional arrays, too. A pair of brackets (the array subscript operator—[ and ]) indicates a dimension.
  •     The compiler can automatically calculate the memory space needed by an unsized array.

 

 

Related Items

More Examples of Disk File I/O

More Examples of Disk File I/O

The following sections show several more examples of disk file I/O, such as reading and writing binary data and redirecting the standard streams. Three more I/O functions, fscanf(), fprintf(), and freopen(), are introduced, too.

Random Access to Disk Files

Random Access to Disk Files

Exercises : Answer the following Question

To help solidify your understanding of this lesson, you are encouraged to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson.

Question and Answer

    Q What are the differences between a text stream and a binary stream?

Reading and Writing Disk Files

Reading and Writing Disk Files