6.6 ARRAY AS STRING

6.6 এৰে এজ ষ্ট্ৰিং

In most of the programs above, we have taken the array of type int. In a few cases, we have taken char type arrays. A string is defined as an array of characters. The last character in a string is a special character ‘\0’. This is also called the NULL character in a string. The NULL character is to indicate the end of the valid characters of the array.

ওপৰৰ বেছিভাগ প্ৰ’গ্ৰামত, আমি প্ৰকাৰৰ ইণ্টৰ এৰে লৈছো। কেইটামান ক্ষেত্ৰত, আমি চাৰ প্ৰকাৰৰ এৰে লৈছো। এটা স্ট্ৰিংক বৰ্ণৰ এৰে হিচাপে সংজ্ঞায়িত কৰা হয়। এটা স্ট্ৰিংত অন্তিম টো চৰিত্ৰ হৈছে এক বিশেষ চৰিত্ৰ ‘G 0’। ইয়াক এটা স্ট্ৰিংত এনইউএল বৰ্ণ বুলিও কোৱা হয়। এন.ইউ.এল. বৰ্ণটো হৈছে এৰেৰ বৈধ বৰ্ণবোৰৰ সমাপ্তি সূচিত কৰা।

There is a dedicated header file in C called string.h that supports many library functions for strings. Let us see a simple C program in Example 6.14 that takes a string as input and displays that string. We used gets() function to take the input from the keyboard and puts() function to display it.

স্ট্ৰিং.এইচ নামৰ চি-ত এটা সমৰ্পিত হেডাৰ ফাইল আছে যি স্ট্ৰিংৰ বাবে বহুতো লাইব্ৰেৰী ফাংচন সমৰ্থন কৰে। উদাহৰণ 6.14-ত আমি এটা সৰল চি প্ৰ’গ্ৰাম চাওঁ আহক যিয়ে ইনপুট হিচাপে এটা স্ট্ৰিং লয় আৰু সেই স্ট্ৰিংটো প্ৰদৰ্শন কৰে। আমি কীবোৰ্ডৰ পৰা ইনপুট ল’বলৈ গেট() ফাংচন ব্যৱহাৰ কৰিছিলো আৰু ইয়াক প্ৰদৰ্শন কৰিবলৈ ফাংচন টো ৰাখোঁ।

The string.h header file supports many library functions for performing operations on strings. We will see one such function strlen() in Example 6.15. The function returns the length of the string, that is the number of characters in the array. We use this in the for loop to go through the array elements and to display them one by one.

স্ট্ৰিং.এইচ হেডাৰ ফাইলে স্ট্ৰিংত কাম কৰাৰ বাবে বহুতো লাইব্ৰেৰী ফাংচন সমৰ্থন কৰে। আমি উদাহৰণ 6.15-ত এনে এটা ফাংচন ষ্ট্ৰেলেন() দেখিম। ফাংচনটোৱে স্ট্ৰিংটোৰ দৈৰ্ঘ্য ঘূৰাই দিয়ে, যি হৈছে এৰেৰ বৰ্ণৰ সংখ্যা। আমি ইয়াক এৰে উপাদানবোৰৰ মাজেৰে যাবলৈ আৰু সেইবোৰ এটা এটাকৈ প্ৰদৰ্শন কৰিবলৈ লুপৰ বাবে ব্যৱহাৰ কৰোঁ।