Results 1 to 10 of 14

Thread: [C] The lousy random question thread

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    hey, 2nd C question, yee

    1)

    > but why do i have to write it this way: (int *)&a and not (int)*(&a)?
    everything in the () is nothing but a *type*. so (int *) is just representig the type of a int-pointer.


    > would be (int*)&a be the same, without the space between int and *?
    yep, totally the same

    > is the dereferenc-star * assigned to the int-cast or to the adress here?
    in the context of a cast (int *) it is *not* dereferencing anything. it just indicates that is *is* a pointer and can be referenced later.

    you can derefence references as often as you want and make jokes out of it:

    PHP Code:
        int i 4;
        
    printf("%d", *&*&*&*&i); // prints 4

        // thats the same:
        
    printf("%d", *(int *)&*&i); // 4 

    p = malloc( count * sizeof( int * ) );
    size of what? an int-pointer?
    yea, the size of a int-pointer. on 32bit = 4 byte, on 64bit = 8byte
    p is a pointer-on-a-pointer... when you derefence it once, it is still a pointer, so you need to derefence it twice (**p). it's not needed in that example. ^^

    2) you dont need to write any 1.0 or 1.0f

    you can just write:

    PHP Code:
    float delta 1
    every compiler is smart enough to recognise, what you want.
    timescale 0.01

  2. The Following User Says Thank You to kung foo man For This Useful Post:

    serthy (1st April 2013)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •