Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (16)

Sign In or Sign Up now to post a comment!
  • 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

  • Where is part #2? -___-

  • C++ IS OLD!!!!!

  • @lepeanut

    What's your point? It's still an industry standard.

  • 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(charactervariabl­earrayhereorsomething))? Or it doesn't really matter how much memory you allocate at all?

  • @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.

  • mmmmmmm, now i am getting excited !!!!! thank you.

  • another main reason to use dynamic memory allocation in both C and C++ is if you are only going to know the size of that piece of memory at run time. it is illeagel to do this

    int x = 100;

    int y[x];

    but with dynamic memory allocation it is possible.

  • @amino0o is there an explanation to why this is illegal? i thought it was possible until you said the opposite. I don't know much C but in other languages I tryied it was possible to do what you mentioned.

  • @amino0o i just tryied that code and it works..

  • @pithikoulis maybe in declaration but certainly not in operations , its down to the compiler

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more