Computer Software

How can a pointer be initialized in C?
Answered by Discovery Channel
  • Discovery Channel

    Discovery Channel

  1. In the C programming language, pointer variables are initialized when the pointer points to a known area in your system's memory. There are four ways to accomplish this:

    • Use the malloc statement, which designates a block of memory and then directs the pointer to it. The pointer is initialized because it's been filled with the address of the new memory block.
    • Use a statement like p = q, where q points to a valid memory block. The pointer p will be initialized, because q is already directed at a valid address.
    • Direct the pointer to an address that is already known.
    • Use the value zero with a pointer. Any pointer can be set to zero, and in this state it won't be pointed toward any memory block. It will instead be used as a tag.

     

    More answers from Discovery Channel »



Still Curious?
  • What are some drawbacks to using a Web OS?


    Answered by HowStuffWorks

  • How did you shift from computer science at MIT to art in Japan?


    Answered by John Maeda

  • What are log files?


    Answered by Planet Green

Advertisement

What are you curious about?

Image Gallery