কম্পিউটার টিউটোরিয়াল

সি ভাষায় পয়েন্টার কনসেপ্ট প্রদর্শন


পয়েন্টার হলো একটি ভেরিয়েবল যা অন্য ভেরিয়েবলের অ্যাড্রেস সংরক্ষণ করে।

সিনট্যাক্স

pointer = &variable;

উদাহরণ প্রোগ্রাম

#include<stdio.h>
void main() {
    int a = 2;
    int *p;
    p = &a;
    printf("Size of the integer is %d\n", sizeof(int)); // 4
    printf("Address of %d is %d\n", a, p);
    printf("Value of %d is %d\n", a, *p); // 2
    printf("Value of next address location of %d is %d\n", a, *(p+1)); // গার্বেজ ভ্যালু
    printf("Address of next address location of %d is %d\n", a, (p+1)); // অ্যাড্রেস + 4

    // টাইপকাস্টিং পয়েন্টার
    char *p0;
    p0 = (char*)p;
    printf("Size of the character is %d\n", sizeof(char)); // 1
    printf("Address of %d is %d\n", a, p0);
    printf("Value of %d is %d\n", a, *p0); // a-এর প্রথম বাইট - 2
    printf("Value of next address location of %d is %d\n", a, *(p0+1)); // দ্বিতীয় বাইট - 0
    printf("Address of next address location of %d is %d\n", a, (p0+1)); // অ্যাড্রেস + 1
}

আউটপুট

Size of the integer is 4
Address of 2 is 6422028
Value of 2 is 2
Value of next address location of 2 is 463824
Address of next address location of 2 is 6422032
Size of the character is 1
Address of 2 is 6422028
Value of 2 is 2
Value of next address location of 2 is 0
Address of next address location of 2 is 6422029
  1. C প্রোগ্রাম: পয়েন্টারের উদাহরণ প্রদর্শন

  2. সি ভাষায় পয়েন্টার দিয়ে অ্যারিথমেটিক অপারেশন

  3. সি ভাষায় শিফট অপারেশন (লেফট, রাইট শিফট এবং কমপ্লিমেন্ট)

  4. সি ভাষায় পয়েন্টার অ্যাক্সেসিং ধারণা ব্যাখ্যা