Strings In C: C Tutorial In Hindi #34

  Рет қаралды 400,191

CodeWithHarry

CodeWithHarry

Күн бұрын

Пікірлер: 711
@pythonkrishna290
@pythonkrishna290 Жыл бұрын
str[5] can only store 5 characters. The strinng (or character array) "hello" has 5 characters so there's no space for the null character(\0). For those who are wondering that by using double quotes ("") the compiler will automatically add a null character(\0) should remember that altough it's true but the compiler will need an extra space in that array to store the null character(\0) which is limited in the character array str. Hope I am right...
@adityadoijad8091
@adityadoijad8091 10 ай бұрын
The array str is declared with a size of 5 (char str[5];), which means it can store only 4 characters plus the null terminator ('\0'). However, the string "hello" has 5 characters.
@bilalrajput1428
@bilalrajput1428 5 ай бұрын
yes Right Answer 🙂🙂🙂🙂🙂🙂
@deltashorts9
@deltashorts9 5 ай бұрын
Right
@priyanujbora9689
@priyanujbora9689 3 жыл бұрын
char str[5]; str="hello"; str is a constant pointer to str[0] and its value is not modifiable; if str[0] is modified first then this constant pointer can be modified
@sirkartik
@sirkartik 2 жыл бұрын
bro can u pls explain this further?
@yashrawat747
@yashrawat747 2 жыл бұрын
@@sirkartik bhai hello 5 characters se bna hh abb hmey ek aur space chaiye h jhan pr hum \0 issey store kr payen
@sirkartik
@sirkartik 2 жыл бұрын
@@yashrawat747 Thanks :) for replying bro
@harshitsingh2101
@harshitsingh2101 2 жыл бұрын
@@yashrawat747 Galat hai bhai, dekho jo str hai wo yaha par array pointer ki terah kaam kar raha hai agar tumne str = "hello" likha matlab tum str[0] ke address ko equal kar rahe ho "hello" ke toh compiler tuhme wo karne nhi deta instead do char *str[(this value doesn't matter)]; *str = "hello";
@twinklerambhia3236
@twinklerambhia3236 2 жыл бұрын
str[5] is an array that can store upto 5 characters only. h e l l o is 5 characters, since the 6th character is a null character the array size has t be 6. Hence, str[6] should be used for storing h e l l o.
@adnankaisar12
@adnankaisar12 2 жыл бұрын
Sir as you said and we all know element of an array started from 0 so char str[5] is correct according to me cause it has 6 spaces so we can include '\0' too in that if i write "harry". I'm confused sir, coreect me if im wrong.
@iliyonhunyawr
@iliyonhunyawr 2 жыл бұрын
When we declare an array with any index number then its mean its locations is one less of it For example str[5] have 0,1,2,3,4 locations so we have to declare another location for null
@PR_Pavan
@PR_Pavan Жыл бұрын
#include int main() { char str[6] = "PAVAN"; for(int i=0; i
@gorakhraut5138
@gorakhraut5138 5 жыл бұрын
str[5],str="hello" we are unable to store this "hello" into str[5] array. the reason is "\0" we are not adding null character into this array.
@soniamalik4929
@soniamalik4929 4 жыл бұрын
But...harry ne bola tha ki "hello" wale method m compiler khud hi create krega null character?plz answer
@liltekos4498
@liltekos4498 4 жыл бұрын
@@soniamalik4929 kyonki usme humne string ka size define kiya hai 5 ,agar vo 5 voha na hota to vaise hi hota jaise tum bata rahi ho compiler bhi automatically lagata hai \0 but uske liye bhi space honi chaiye na isliye
@vikassaini7485
@vikassaini7485 4 жыл бұрын
@@liltekos4498 Have you run this code on your computer? This code is showing me error instead of writing str[6]
@starkendeavours7072
@starkendeavours7072 4 жыл бұрын
@@vikassaini7485 Yes, bro I just checked. If you write str[5], It's actually not giving an error but instead of hello some unusual letters are getting appended with "hello". But str[6] gives no errors and unsatisfied results.
@BiswajitPatra-xn6xw
@BiswajitPatra-xn6xw 3 жыл бұрын
@@soniamalik4929 yup compiler do this own. But tell me to stay you require a room space ri8, is it matters whether you created the room or the builder created for u?????///
@tokyotalkiesfromIND1A
@tokyotalkiesfromIND1A 3 жыл бұрын
Str[5 ] can store only 5 characters while the string ''hello'' itself has 5 character. hence , there is no space for \0(null character) .
@Chess_.64
@Chess_.64 2 жыл бұрын
O(n+1)
@rohitgiri9179
@rohitgiri9179 2 жыл бұрын
no bro if we are using double quote("") then no need of null character
@AniketSingh-be5gk
@AniketSingh-be5gk Жыл бұрын
Bhai aapka knowledge toh kamaal ka hai😂
@adityar.b.8979
@adityar.b.8979 Жыл бұрын
@@rohitgiri9179 null character will still be needed even if we use double quotes and so space to allocate it should also be there. It's just that we won't need to write \0 at the end. Double quotes by default takes a \0 at the end.
@harshbhalala9387
@harshbhalala9387 Жыл бұрын
@@AniketSingh-be5gk 🤣🤣
@triptipal58
@triptipal58 3 жыл бұрын
How could someone be this much nice..I mean teaching for free all the concepts and that too in understanble form...applaudssss🎉
@chirntn
@chirntn Жыл бұрын
Please note that the gets function is considered unsafe and has been deprecated in newer versions of the C standard due to potential buffer overflow vulnerabilities. SO better use fgets( str , sizeof(str), stdin);
@surajprajapati3627
@surajprajapati3627 2 жыл бұрын
str[5] initialise from 0 to 4, which only can store upto 5 char so null char cann't be added by compiler.
@yogeshkolate8207
@yogeshkolate8207 3 жыл бұрын
The size of array of string should be greater than 1 from actual size of array to store null character (\0) ie. Ln+1
@CODINGCLASS-e5w
@CODINGCLASS-e5w 29 күн бұрын
Char str [5]; Str="hallo"; Bas ek kaam karna hai 5 ki jagah hume 6 likh dena hai null.\0 ke liye Hame apne charcter se space ko chhota nahi likhna chaho to bda kitna bhi likh sakte ho magar null \0 ke liye jagah deni padegi
@lovishbansal3789
@lovishbansal3789 3 жыл бұрын
char str[5]; str = "hello"; This will create problem because we have length of hello word 5 and in str we can store only 5 character but for string we need length of character+1 in array created
@soumyajitmukherjee3122
@soumyajitmukherjee3122 2 жыл бұрын
As "hello"={'h', 'e', 'l', 'l', 'o', '\0'} exceeds the stack by 1 character and by definition given above is char srt[5], of strength 5. That's why the compiler will through error.
@tishagupta3136
@tishagupta3136 2 жыл бұрын
The str[5] represents an array which only stores 5 character and hence to make it a proper string we have to increase the length by 1 to store the null value too. That will make it a perfect string and hence then it will print harry and run without creating an issue
@taufiqueanwarkhan2396
@taufiqueanwarkhan2396 11 ай бұрын
02:43 Strings are not a data type in C programming, but they can be represented using character arrays. 05:26 A string in C is an array of characters terminated by a null character. 08:09 C programming uses character arrays to represent strings. 10:52 In C programming, strings are null-terminated character arrays. 13:35 Using arrays to model strings in C and printing them using %s or putsstr 16:18 Explanation of character arrays in C 19:01 Understanding string handling in C 21:37 Different ways to print strings in C
@SadharanLadkaIsBack
@SadharanLadkaIsBack 9 ай бұрын
str = "hello" consists of 5 characters and when it's checked by the C compiler gcc then it adds a null character in the end and so the size is 6 but it is initialized with char str[5]; so the second line will throw error as there's no problem in initializing the array but the index is overlapping the declared size of the character array
@codificatore_05
@codificatore_05 10 ай бұрын
9:38 Bcoz sir array size is 5 and bcoz we have put double quotation therefore there's no space for it. Hence the string will be printed with garbage values ..So the space should be increased .
@sarveshdevrukhakar
@sarveshdevrukhakar 3 жыл бұрын
Firstly, ANSWER of your question is ( because when we right any word in double-quotes that time compiler automatically applies the NULL character ( '\0' ) ; so, above your line is never create any issues. Ok ! Then 2nd thing is , when you explaining the "printstr" function that time you say " i will tell you ki why iam used %c in printf . But after sometime you forgot that...🙄🙁 But its okay. 🤩🙌👌👍 You are AWESOME guy.. No doubt..👍👍
@SwarnadipDutta
@SwarnadipDutta 4 ай бұрын
str is a pointer to the base element of the char array str [ ] , so we cannot store "hello" in it because it is not a char array. Besides , the value of str is not modifiable.
@srinibaspanigrahi8558
@srinibaspanigrahi8558 3 жыл бұрын
The str[5] is a character array that can store 5 elements, but to store 'harry' 6 characters are required.
@bijendraagrawal2411
@bijendraagrawal2411 3 жыл бұрын
Because of null character
@lalith_kumar_akhila2411
@lalith_kumar_akhila2411 2 жыл бұрын
@@bijendraagrawal2411 '\0'..
@aryanagarwal7903
@aryanagarwal7903 2 жыл бұрын
hello not harry😅
@harshbhalala9387
@harshbhalala9387 Жыл бұрын
@@aryanagarwal7903 🤣🤣🤣🤣🤣🤣
@fanimedubb8879
@fanimedubb8879 Жыл бұрын
@@aryanagarwal7903 baat toh smjh gyaa naa
@Diplomaincmtech
@Diplomaincmtech 2 жыл бұрын
Quick quiz ans.= the above line will create problem becaz we need str[ 6] to store hello string and 5 +1 space is needed to print NULL char.
@hritavsinghsolanki8893
@hritavsinghsolanki8893 3 жыл бұрын
char str[5]; str ="harry"; we cant assign an array like this coz its a pointer and that is constant always
@heeru379
@heeru379 3 жыл бұрын
(edited) 9:24 Because it's a C program and you can't assign a string into an array of characters like this. str = "hello"; ❌ str[6] = "hello"; ✔️
@harshitsingh2101
@harshitsingh2101 2 жыл бұрын
No you are very wrong dear
@heeru379
@heeru379 2 жыл бұрын
@@harshitsingh2101 Yes ! You are right I was wrong that time. Thank you I thought earlier it will give error because of null character but the real reason is assignment operator.
@akn3021
@akn3021 2 жыл бұрын
You are wrong....if array size 6 then it is correct
@heeru379
@heeru379 2 жыл бұрын
@@akn3021 Brother, index starts from 0
@ictfan-ly8gh
@ictfan-ly8gh 3 ай бұрын
Still u are wrong 😂
@themoviestory8763
@themoviestory8763 2 жыл бұрын
Char str[5]="hello"; ✓ Str = "hello"; × *You should initialize the value with data type*
@surajprajapati3627
@surajprajapati3627 2 жыл бұрын
This is also wrong
@mohammed-i786
@mohammed-i786 4 жыл бұрын
Quiz answer : Because there is no space to accomodate the null character.
@siddheshdeshpande8618
@siddheshdeshpande8618 Жыл бұрын
in double quotes( " " ) compiler will add a null character to variable hence it will need an extra space is required. Due to this reason line will create an problem. So the size of the string should be at least { length + 1}
@factsandcoding9810
@factsandcoding9810 Жыл бұрын
Sir mast question hai! The real problem is that str is a pointer which stores the base address of character array. we cannot assign a string to it.
@vishalsoner6652
@vishalsoner6652 3 жыл бұрын
Harry bro Mene aap ka 15 hours ka c_language ka pura video dekha he Esh tutorial me aap bohot fast pass rhe ho
@itz_abhi569
@itz_abhi569 Жыл бұрын
str[5] it can store 5 characters but we need 6 characters inclusing a null character as we have already defined the size of string. So by using " " that includes null cahracter the complier can't allow it so that's why it will create a problem
@yashrawat747
@yashrawat747 2 жыл бұрын
sir this is because we have define the character array of only 5 length But what we need is 6 as there are 5 characters and one for null character
@PurviGuptaofficial
@PurviGuptaofficial Ай бұрын
Star[5] liya gaya hai but hame star[6] lena chahiye q ki hello ke sath null character ko bhi count karte hai Correct form char str [6]; str = "hello"; Esa hona chahiye
@proteansan5141
@proteansan5141 3 жыл бұрын
9:46 Because in this type of syntax the compiler automatically takes the \0 which requires an extra memory location so that's why it should be str[6]
@Josuke217
@Josuke217 Жыл бұрын
9:45 initialization and declaration must happen in the same line for strings.
@directionsinfinite4446
@directionsinfinite4446 5 жыл бұрын
bhaiya no problem anywhere if the space of the array would be 6. Please correct me if i am wrong..... Thankq bhaiya for everything..
@vivekanandapradhan9067
@vivekanandapradhan9067 2 жыл бұрын
please cover those cases as well when we do things we are not supposed to do, like if we print a char array without a null character using %s type specifier, what will be the output if we do this, will it be a compilation error, or it will keep on print a long string containing garbage values
@SachinSingh-tr4td
@SachinSingh-tr4td 2 жыл бұрын
Char size will be 6 for null terminated char.
@SisodiyaTech
@SisodiyaTech 4 жыл бұрын
Length of array+1 But there char str[5]; str="hello"; hello is 5 character Null character is needed to terminate
@arunkumartiwari4570
@arunkumartiwari4570 3 жыл бұрын
Good bro
@daughter_of_chitkute0611
@daughter_of_chitkute0611 11 ай бұрын
the compiler adds the null character by itself as we have declared it as a string hence the size would imply that 4 characters for the string and the last character will be reserved for the '\0'. Therefore, we should always give one extra size while declaring the string variable.
@sakshigandhi7363
@sakshigandhi7363 4 жыл бұрын
we supposed to enter str[6]; to solve the problem, bz string size is char+1 for enter"\0"....
@parthatewary738
@parthatewary738 5 ай бұрын
9:50 str[5] can only store 5 char that is h,e,l,l,o so there is no place left for null. So we have to give str[6]
@suhanigupta.3120
@suhanigupta.3120 5 ай бұрын
Same doubt
@parthatewary738
@parthatewary738 5 ай бұрын
Harry wrote str[5] instead of std[ 6]
@parthatewary738
@parthatewary738 5 ай бұрын
​@@suhanigupta.3120so if you do it str[6] it will run as there will be 1 place for /0
@SANJAYDAS-zh7fw
@SANJAYDAS-zh7fw 2 жыл бұрын
9:42 mein len+1 size hona cahiye to accomodate \0 but the size of that array is len not len+1
@ayushmishra5290
@ayushmishra5290 Ай бұрын
str[5] is valid for the string length of 4 character string because of one null character not for 5 string character. For 5 string character we need str[6]
@its_me_456
@its_me_456 2 жыл бұрын
Char str[5] can store only 4 elements with 1 null character for printing "hello" it should be like Char str[6].
@sskilledgame4132
@sskilledgame4132 Жыл бұрын
Lower of area str( ) values of prinrd
@incredibleindiabyrudra7361
@incredibleindiabyrudra7361 2 жыл бұрын
due to bec the str[6] should be there for hello ,for null character too.
@vaibhavbhardwaj48
@vaibhavbhardwaj48 5 жыл бұрын
This is the right way to insert #include int main() { char str[] = "Hello"; printf("%s", str); return 0; }
@SahilSharma-fl4cb
@SahilSharma-fl4cb 2 жыл бұрын
As we need 1 extra space for null character to make it valid string.When we want Hello to print it needs six unit spaces as null character must be include for valid string.
@himanshuagarwal8454
@himanshuagarwal8454 2 жыл бұрын
it will be correct if size would be 6 as it doesnt have space to store null character.
@jayanspaliwal5907
@jayanspaliwal5907 3 жыл бұрын
9:41 This will create a problem because 'hello' will occupy all the space leaving none for the null '\0' character
@vanshikaagarwal1403
@vanshikaagarwal1403 3 жыл бұрын
9:40 length of string will be 6 due to 1 null character /0 and other 5 character of hello and instead of that only 5 is issued so that will create problems.
@Nature-emotionspiritual
@Nature-emotionspiritual 7 ай бұрын
The minimum space required to print the array is 6. But here the space inside character array is 5. No space obtained for null character. That's why it will create a problem.
@shabankachannel330
@shabankachannel330 2 жыл бұрын
because in second line str[10] should be used unstead of str only
@arpangarg1907
@arpangarg1907 Жыл бұрын
Because there is only 5 size in string but its needs to be of size 6 because hello is of 5 size and we need a size of the word and a size of a null character.
@Ashish...114
@Ashish...114 Жыл бұрын
because \0 mandatory h & uske liye length 6 chahiye
@LakshyaKumar-wi3hk
@LakshyaKumar-wi3hk 4 ай бұрын
str[5] can only accomodate 5 characters but wile trying to make a character array/string we need length+1 bytes
@rudranshnemade6299
@rudranshnemade6299 2 жыл бұрын
9.52 Because str has only 5 memory locations but we need 6 location to store Hello and one \0
@manusaini2192
@manusaini2192 Жыл бұрын
There is no space for null character (\0). as you say,( length of string+1) it will store only 5 characters.
@ramanshusharanmishra5397
@ramanshusharanmishra5397 11 ай бұрын
The correct answer to your question is that we cant assign a string to the base adress of an array. and in the given question "arr" represents the base address of an array.
@Abhirup_Maiti
@Abhirup_Maiti 2 жыл бұрын
9:40 char str[5] can store 5 elements only. And str="hello" has 5 characters but we can't store the null character('\0') within str[5]. Thus it is not a valid string.
@aadvikchaturvedi2986
@aadvikchaturvedi2986 2 ай бұрын
9:52 the str only have 5 spaces and the word is also of 5 characters so there would be no space left for null character.
@RohitKumar-wu5vt
@RohitKumar-wu5vt 4 жыл бұрын
It creates probelm becoz we have taken 5 string .and word (hello ) has 5 alphabet So. According to (Len+1) rule you told us it doesn't Print it becoz space for '\0'is not left so that's why it creates problem. Harry bhai
@sanjanapanchal
@sanjanapanchal Жыл бұрын
char str[5], it stores only 5 values,however the str="hello"; " " double quotes defines null character , so now it will display the output =HELLO?
@Chintzz18
@Chintzz18 9 ай бұрын
str[5] can store 4 char and 1 null char and as hello has 5 char already so there will be no space for null char
@lifeforscience5635
@lifeforscience5635 3 ай бұрын
quick quiz answer: because there would be no space to store the null value and thus it would not be as a string to the compiler
@GupteswarGaming
@GupteswarGaming Жыл бұрын
Str 5 can store only 5 character and the word "hello " is already consist of 5 so there is not a null character space 😊
@tamannanegi3621
@tamannanegi3621 8 ай бұрын
Because we have to declare string with the size of 6 to store 5 characters.. because of null character
@UECAshutoshKumar
@UECAshutoshKumar 2 жыл бұрын
Thank you sir ❤️
@tejalmohod9389
@tejalmohod9389 3 жыл бұрын
9:39 Because size is not sufficient for string as it needs to include '\0' as a null character..!!
@manthanpatel1864
@manthanpatel1864 2 жыл бұрын
Char str[6] hona chahiye valid output ke liye Char str[5] sirf 5 length ka word print karega Aur valid output ke liye len + 1 hona bahut jyada jaruri hai
@RadheKrishnaedits9867
@RadheKrishnaedits9867 7 ай бұрын
Because the length of string is 5 and the length of char name is also 5. It has not a sufficient space for NULL character.
@hassnainalidayo5433
@hassnainalidayo5433 2 жыл бұрын
Because array take an input name of array along with each index number
@mohitchouhan7679
@mohitchouhan7679 9 ай бұрын
because array str is delared with a size of 5 .
@captaingaming8333
@captaingaming8333 Жыл бұрын
Str[5] sirf 5 character store kar sakta hai or hello , 5 character ka hai isliye "/0" nahi likh payenge to Str[5] me null character na honeke wajhe se woh valid string nahi hoga to iss wajhe se program execute hone me problem dikhayga..
@TechGenius24x7
@TechGenius24x7 2 жыл бұрын
Null character bhii add Krna hota h isliye apko 6 lena h length +1 fir hojyga
@rosonerri-faithful
@rosonerri-faithful 3 жыл бұрын
9:44 because str array ka length 5 diya gaya hai.. aur hamare string ka length 5 hei..toh \0 accomodate krne ke liye jo extra space chahiye vo hume nhi mil rahi hei. islye error ayga..HarryBhai😁
@Rupesh_Arora
@Rupesh_Arora 3 жыл бұрын
hamare pas '\0' store kane kae liye jagha hi nahi hai or jab tak \0nahi ata to string terminate nahi hongi
@pkmishra7061
@pkmishra7061 3 жыл бұрын
yes it can create problem we have to write str[5]="hello" it will be correct . not str="hello " .
@RohitKumar-ou5uq
@RohitKumar-ou5uq 2 жыл бұрын
As you explained that a string can store (n+1) char if the char intitiliizing is n, but here hello it self is of 5 and there is no space for ' \0' char so thats why it createsa the problem , but here "harry" case also compilers knows that it will put \0 so im confused that how it will creates problems?
@ishaananand4779
@ishaananand4779 2 жыл бұрын
The str[5] is a character array that can store 5 elements, but to store 'harry' 6 characters are required(null character required).
@30day-trader
@30day-trader 2 жыл бұрын
Because is main sirf 5 character store ho sakte hai joki hai "harry" but string ko end karne ke liye "\0" ke store karne ki jagah nhi hai isliye vo error show karega agar yahi pe 6 character store karne ki jagah hoti toh error show nhi hoga
@tamannanegi3621
@tamannanegi3621 8 ай бұрын
But I have a question if we declare a string of 5 size ...and the name is also a 5 characters length so there ..will be no space to .. print garbage values ....so what is the need to store null character ... because it's obvious ..if we declare 7 size and ..if we try to store 5 size string ...there will be garbage ..so adding null character..
@mathtv6526
@mathtv6526 3 жыл бұрын
Because str[5], can store only 5 character not the extra null character (that is - length of array should be one greater than the element's characters value)
@sangeetakharat1933
@sangeetakharat1933 Жыл бұрын
String 5 can store only 5 digits and the "hello" itself has 5 digits and because of the semicolon it will also add \o(null character) but there is no space to store the \o character.ok
@er.skelafahmed
@er.skelafahmed 3 жыл бұрын
Str[6] will be correct because of hello=5 char, " " = 1 char ,total =6 char
@jaykumarpawar08
@jaykumarpawar08 3 жыл бұрын
Means, char str[6]={'h','e','l','l','o','/0'}; 🙃
@jaykumarpawar08
@jaykumarpawar08 3 жыл бұрын
I hope you understand 😀
@gyanwalatech1787
@gyanwalatech1787 4 жыл бұрын
It will create problem because the legth of character is 5 and the 'hello' word's total length also 5. But for string after the total length of the word one letter should be reserved for null character. So it will occur error
@chiteez_____1562
@chiteez_____1562 Жыл бұрын
Quiz solution: Since the array length = string length , therefore, the compiler will get no space to add ''\0' in the end and as a result it will not be considered as an string.
@rumankhan7303
@rumankhan7303 Жыл бұрын
Bcoz Size of string is 5 But we need to more size than current size String size =length +1;
@MizanurRahaman03
@MizanurRahaman03 4 жыл бұрын
"\0"is not use into this str[5] character .if we declare str[6] then it is a valid statement .
@yourfitnessadda2860
@yourfitnessadda2860 3 жыл бұрын
because as you said to strong a value in string we have to assign string as length of string +1
@vaishnavisharma4137
@vaishnavisharma4137 3 жыл бұрын
this lecture really help me a lot bhaiya to learn about strings very clearly. thanks a lot bhaiya for your videos and appreciable effort.
@memeviral6546
@memeviral6546 4 жыл бұрын
String one dimension array So represent by Char str[5]; Str[5]="hello";
@devasyarajguru1873
@devasyarajguru1873 3 жыл бұрын
char str[5]; and str = " hello "; . ---->> Here the program will create problem because we the array is of 5 length and string stores the value of (length+1) so total 6 which means it includes the null character but our char array is of only 5 length so it will create problems. :))
@kalyugkakrishna5970
@kalyugkakrishna5970 3 жыл бұрын
Sir, time 20:03 pr aapne kha he ki ham scanf me Wight space nahi le skte to asa nahi he! Mene "Let us C" book me pda he . . . scanf (" %[^ ]s "
@ansh4802
@ansh4802 2 жыл бұрын
Str[5] can store only 5 character so there is no space left for \0(null character)
@sumitkadam6773
@sumitkadam6773 3 жыл бұрын
Cahr str[6]; is correct ,Cause we have a one more space for '\o'
@phantomfury1608
@phantomfury1608 Жыл бұрын
The word "hello" will create problem because it is a 5-letter word. In the code we have assigned the maximum value that the array can accommodate is up to 5. But while using string we have to denote '/0' in the array code to signify that the string ends here and not to print the garbage value further. So, array required to accommodate given string has to be number of characters in string +1 which is used to denote null character. Therefore, in the code shown, after accommodating the 5 characters of "hello" in the array, there will be no room for denoting null character which will create the problem in the code.
@Flagshipcoding
@Flagshipcoding 2 жыл бұрын
we have to use relative operator instead of assignment operator other we have to face error
@vivekhalder2974
@vivekhalder2974 2 жыл бұрын
the above snippet will create a problem because we are storing "hello" but '\0' character will also require a space which is not present as the size of the array is declared to be 1.
String Functions In C & string.h Library: C Tutorial In Hindi #35
18:49
Pointers In C: C Tutorial In Hindi #26
32:46
CodeWithHarry
Рет қаралды 796 М.
Perfect Pitch Challenge? Easy! 🎤😎| Free Fire Official
00:13
Garena Free Fire Global
Рет қаралды 67 МЛН
Triple kill😹
00:18
GG Animation
Рет қаралды 18 МЛН
Yay, My Dad Is a Vending Machine! 🛍️😆 #funny #prank #comedy
00:17
Try Not To Laugh 😅 the Best of BoxtoxTv 👌
00:18
boxtoxtv
Рет қаралды 7 МЛН
C_62 Strings in C - part 1 | C programming tutorials
15:41
Jenny's Lectures CS IT
Рет қаралды 506 М.
Structures In C: C Tutorial In Hindi #37
26:18
CodeWithHarry
Рет қаралды 484 М.
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Brian Will
Рет қаралды 2,1 МЛН
Strings & Character Arrays in C++  -  Part 1 | DSA Placement Series
30:03
Passing Arrays As Function Arguments: C Tutorial In Hindi #32
24:04
CodeWithHarry
Рет қаралды 264 М.
Call by Value & Call By Reference In C: C Tutorial In Hindi #31
27:30
CodeWithHarry
Рет қаралды 360 М.
Perfect Pitch Challenge? Easy! 🎤😎| Free Fire Official
00:13
Garena Free Fire Global
Рет қаралды 67 МЛН