malloc(10*sizeof(int)) It allocates a memory block of size 40 bytes. calloc(10, sizeof(int)) It allocates 10 contiguous memory blocks each of size 4 bytes.
Sir but when we pass in malloc only any numerical value like 10 . And we say malloc is DMA but when we pass any numerical value instead of taking input by user. That time, can we say it is dynamically allocated?
Thank you sir... for this video can you use digital writing pad and try to explain all the future content by using that... it will be very helful for us.. to grasp the concept .. i have seen lots of tutorials on coursera, Udemy, Lynda they use digital Pad... they are good but u r just amazing... Hindi mei padhne ka maza he kuch aur hai... and the content is marvellous and unique....😊
Sir, I was looking for the video under this title as I wanted to confirm the difference that whether malloc initializes with no default value, but calloc initializes with zero value by default. Is it true?
could you please explain what is the actual difference in malloc and calloc in terms of it allocates the DMA? if we multiply size of () in malloc with 10 and in calloc if we pass first argument 10 then what will be the difference. It will allocate the same size according i understand but then what will be the difference ?
malloc(10*sizeof(int)) It allocates a memory block of size 40 bytes. calloc(10, sizeof(int)) It allocates 10 contiguous memory blocks each of size 4 bytes.
balaguruswamy , c++ primer are good books .. u can also try cplusplus.com , tutorials points and when u learn all these then try the book by bjarne stroustrup the creater of c++(but this book is too hard for a beginner)
i'ts depend on the compiler not on the computer like if you are using a turbo compiler then int has 2 byte and if some other compiler like gcc int take 4 byte
But saurav sir khte h ki 16 bit dos arcitecture me int 2 byte 32 bit dos me 4 byte hota h and so on.. To is hisab se to humare o. S se decide hora h ki datatype kitni memory lega na ki compiler.
sizeof(int) is not a constant across all platforms. It varies from system to system or compiler to compiler. Only sizeof object which is constant across all platforms is sizeof(char) [sir is also right]
The same way as a function in your program may returns values to indicate its result, main returns to indicate the result of execution of your program. also in case int main() does return explicit, compiler will put return 0 automatically
may be it's quite high project but i am also make a project in machine learning using python the project is same as google voice capture . you can input a data in form of voice like i am saying [tell me something about c++ ] so he search the web and gave the result in from of voice and all the api i am building my self but it's quite a difficult project i am with 3 other people working on this project if you have a group of 3-4 people you can also make something like this
Sir Mera doubt ye Hai k agar ma char* a = (char*)malloc(6*sizeof(char)); karta Hun memory allocation character pointer k liye......to pahla index.....I mean a[0] ko print karwata Hun to hamesha null value aati Hai......I mean agar allocation k pad ma data input karaun......aur print out lun......to hame pahla alphabet index 1 SE start hota Hai na ki index 0 se... Sir please look into this.....aisa kyun hai
#include #include int main() { char* ptr=(char*)malloc(6*sizeof(char)); scanf("%s",ptr); for(int i=0;ptr[i];i++) printf("%c ",ptr[i]); } check out this i don't think there is any problem index always start from 0
struct student { int x; structure student *p; }; F1() { struct student *m; m=(struct student)malloc(8); } Sir F1 Function me m variable behave like a SMA variables Ya DMA variable.
HIT LIKE IF U CONSIDER SAURABH SIR AS THE BEST C TEACHER
Swarnava Chatterjee awesome
Not only C. For every subject sir is awesome!!!
Selfless teacher!
Sir you are doing good work...
Well done .... tnx you so much sir
you are great sir
malloc(10*sizeof(int))
It allocates a memory block of size 40 bytes.
calloc(10, sizeof(int))
It allocates 10 contiguous memory blocks each of size 4 bytes.
Yes
Thank you sir, love your explanation
Nice explaination sir...my like number 400☺️
Awesome explanation sir
crystal clear sir!!
Sir but when we pass in malloc only any numerical value like 10 .
And we say malloc is DMA but when we pass any numerical value instead of taking input by user.
That time, can we say it is dynamically allocated?
What will be the value initialized by calloc if dynamically created variable are not of primitive type?
Bhut sahi sir
Sir thanks for the video
nice video sir
Sir structure ke upar videos bnao plss
Thank you sir... for this video
can you use digital writing pad and try to explain all the future content by using that... it will be very helful for us.. to grasp the concept ..
i have seen lots of tutorials on coursera, Udemy, Lynda they use digital Pad...
they are good but u r just amazing... Hindi mei padhne ka maza he kuch aur hai...
and the content is marvellous and unique....😊
thanks sir..
Sir, I was looking for the video under this title as I wanted to confirm the difference that whether malloc initializes with no default value, but calloc initializes with zero value by default. Is it true?
In malloc values at allocated memory are initialised by garbage value
In calloc values at allocated memory are initialised by 0
Thank you sir
could you please explain what is the actual difference in malloc and calloc in terms of it allocates the DMA? if we multiply size of () in malloc with 10 and in calloc if we pass first argument 10 then what will be the difference. It will allocate the same size according i understand but then what will be the difference ?
malloc(10*sizeof(int))
It allocates a memory block of size 40 bytes.
calloc(10, sizeof(int))
It allocates 10 contiguous memory blocks each of size 4 bytes.
sir why peek returns (top-1) during dynamic stake programs
Thanks for this video...sir...
sir plzz make campus preparation videos also for c++
visit www.mysirg.com for campus content
Sir operating system ke video bnaie plz
achi viedo ha
Thanxx sir ji
Sir what is memory management?
sir, can you provide the PYTHON course online .......PLEASE sir.
Thanks sir
nice video
How the free func. Know that if two ptr with same name then which memory block to free
Sir I can not find your video of prepration for MCA enterance exam..sir please give me link for study.
Sirji c++ sikhne ke liye kon sa book achcha rhega........
Go with Ravichandran's book on C++. Trust me brother this book is amazing for c++.
balaguruswamy , c++ primer are good books .. u can also try cplusplus.com , tutorials points
and when u learn all these then try the book by bjarne stroustrup the creater of c++(but this book is too hard for a beginner)
Lekin sir apny malloc( ) sy hi dynamic array bnay h data structures ki videos may 😮
Sairaj Das 8:35 dekh
sir java me interview question dalo jaldii se like
soon
MySirG.com plz. sir
When will u upload Advanced lecture of android
SIr plz ye btaete ki alg alg bit k compiler mr kaisr decide hota h ki int char float double ko kitni byte memory milege. Plz sir
i'ts depend on the compiler not on the computer like if you are using a turbo compiler then int has 2 byte and if some other compiler like gcc int take 4 byte
But saurav sir khte h ki 16 bit dos arcitecture me int 2 byte 32 bit dos me 4 byte hota h and so on.. To is hisab se to humare o. S se decide hora h ki datatype kitni memory lega na ki compiler.
sizeof(int) is not a constant across all platforms. It varies from system to system or compiler to compiler.
Only sizeof object which is constant across all platforms is sizeof(char) [sir is also right]
Plz thoda simple way me smjana bhai.
You can find the size of different data types by sizeof(data_type) operator.
thanku sir.......
Sir Main function return int value in c++ why
just to tell the operating system that the program is executed properly
Then why main function is not give void type value
The same way as a function in your program may returns values to indicate its result, main returns to indicate the result of execution of your program. also in case int main() does return explicit, compiler will put return 0 automatically
www.geeksforgeeks.org/fine-write-void-main-cc/ read this
Thanks sir
c++ fatal error no such file or directory... sir ye problem kese solve hogi
Jay bheem namo buddhay jay bharat
I am writing from lot's of time
Sir mana 2 management system bana rkhe h java se .but kuch aur tarah ka kya ban sakta hai management system ka alawa samj nhi aa RHA.
you can make web application like paint application, key logger, web browser, music player
Cook The Code all these are already made up and much better than what I can make
may be it's quite high project but i am also make a project in machine learning using python the project is same as google voice capture . you can input a data in form of voice like i am saying [tell me something about c++ ] so he search the web and gave the result in from of voice and all the api i am building my self but it's quite a difficult project i am with 3 other people working on this project if you have a group of 3-4 people you can also make something like this
Cook The Code I am alone here to make project
Cook The Code I m unable to understand what other things can we make with java swing
sir premium.my sirg.com kb Star hoga
Start
Sir Mera doubt ye Hai k agar ma char* a = (char*)malloc(6*sizeof(char)); karta Hun memory allocation character pointer k liye......to pahla index.....I mean a[0] ko print karwata Hun to hamesha null value aati Hai......I mean agar allocation k pad ma data input karaun......aur print out lun......to hame pahla alphabet index 1 SE start hota Hai na ki index 0 se...
Sir please look into this.....aisa kyun hai
#include
#include
int main() {
char* ptr=(char*)malloc(6*sizeof(char));
scanf("%s",ptr);
for(int i=0;ptr[i];i++)
printf("%c ",ptr[i]);
}
check out this i don't think there is any problem index always start from 0
treat 'a' as ponter but not as array. i did the same thing what you asked and i got the desired output too in the code blocks ide
yeah index starts with 0 with ptr[0] will give 0 and the first character always starts with index ptr[1]...
you mean *(a+0) this to be printed out
its not gonna solve the problem man
Why the malloc bidefault value is garbage?? And say about calloc also
struct student
{
int x;
structure student *p;
};
F1()
{
struct student *m;
m=(struct student)malloc(8);
}
Sir F1 Function me m variable behave like a SMA variables Ya DMA variable.
SMA because it is declared above.
Sir please upload android lecture
visit premium.mysirg.com
Sir ye to kr chuka advanced k liye bol rha hn sir
java
Thanks sir