অনুরূপ অনেক 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

মডুলার C প্রোগ্রামিং (Modular C Programming)

কেবল মাত্র একটি ফাংশন দিয়ে কোনো বড়ো জটিল সমস্যা সমাধানের চেষ্টা করা ভাল প্রোগ্রামিংয়ের পদ্ধতি নয়। সঠিক পদ্ধতি হ'ল সমস্যাটিকে কয়েকটি ছোট ছোট এবং সরল টুকরো করে ফেলা যাতে তা আরও বিশদে বোঝা যায় । তারপরে এই ছোট এবং সরল সমস্যাগুলি সমাধান করার জন্য ছোট ছোট ফাংশন ব্লক তৈরি করা এবং পরে সেগুলি নিয়মানুযায়ী সংযোজিত করা ।

Programming Style

Programming Style

In this section, I'd like to briefly highlight some points that will help you write clean programs that can easily be read, understood, and maintained.

Exercises : Answer the following Question

To help solidify your understanding of this hour's 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 Is the C preprocessor part of the C compiler?

    A No. The C preprocessor is not part of the C compiler. With its own line-oriented grammar and syntax, the C preprocessor runs before the compiler in order to handle named constants, macros, and inclusion of files.

Compiling Your Code Under Conditions

Compiling Your Code Under Conditions

You can select portions of your C program that you want to compile by using a set of preprocessor directives. This is useful, especially when you're testing a piece of new code or debugging a portion of code.