C Programming Tutorial # 33 - malloc() and free() - Dynamic Memory Allocation - Part 1 [HD]
Uploader Comments (Learnorama)
All Comments (16)
-
when i do it in dev-c++ the compiler declare an error (invalid conversion ffrom ' void*' to 'int*'
please can you help me
-
good tutorial. i was worried because they complain about part 1 not being here.
-
@pithikoulis The newest C standard allows this, I believe; arrays on the stack without a constant length used to be illegal and so many people heard it and think it's wrong
-
Thank you for the tutorial. I was wondering what is this stack and why would i need to ever use malloc.
-
His voice gets increasingly loud xD
Very good tutorial btw, for learning malloc(), free() etc.
-
your voice reminds me of a prankcaller in @OwnagePranks :D
-
What's your point? It's still an industry standard.
-
Where is part #2? -___-
-
@pithikoulis maybe in declaration but certainly not in operations , its down to the compiler
-
@amino0o i just tryied that code and it works..
Could you use malloc to allocate memory for a "fixed number" of bytes that is "specified" by the user? Lets say, you're storing 100 different types of words. Instead of creating a character array such as:
char pWords[10000];
which in this video, you stated is bad, since it might overwrite a different program's stack (which may result in a crash).
Hence, could you do malloc(strlen(charactervariablearrayhereorsomething))? Or it doesn't really matter how much memory you allocate at all?
itsdannyftw 1 year ago
@itsdannyftw Yes, you can use malloc to allocate any number of bytes. Just specify the number. And this number can be input from the user, or it could be the length of a string, whatever.
Learnorama 1 year ago