Like coding, try to answer this question.. if you can.
Register

We are the best invite forum on the internet! Here you will find free invites, free seedboxes, free bonuses, and much more. Our members know the true meaning of sharing and have created a truly global bittorent community! Our site has the most up to date information on all private trackers and our members will guide you and introduce you to this truly secretive and enlightened club. Ready to get started? Register now!


Results 1 to 5 of 5
  1. #1

    Join Date
    Jan 2012
    Location
    USA
    Posts
    8

    Default Like coding, try to answer this question.. if you can.

    Obviously this isn't a program and it will not compile it is just a question involving C and I thought some people might enjoy trying to figure it out. Anyway here goes.. and good luck :). btw... yes there is a logical solution.

    void ***q=malloc(8);
    *q=q;
    *((long long *)*q)=0x012345678abcdef;
    what is the value of (int)*((char *)q) ?



  2. To remove ads become VIP. Inquire about advertising here.
  3. #2
    darkma77er is offline darkma77er's Avatar On The Chopping Block

    Join Date
    Jan 2012
    Location
    Germany
    Posts
    16

    Default

    That's tricky...

    I think it is 48 but I'm not sure...

    I hope my upcoming programming exam will not be that hard. :D

  4. #3

    Join Date
    Jan 2012
    Location
    USA
    Posts
    8

    Default

    Nope. Let me give you a hint starting it out... Maybe you will be able to figure it out with some clues..

    (int) - casts an int
    void ***q = pointer to pointer to pointer to void.
    malloc(8) = pointer to 8 writable bytes.
    "*q=q" = set the first 4 of those bytes to point to themselves.
    Like if the bytes are at 0x11223344, the list of bytes will go 0x44,0x33,0x22,0x11,?,?,?,?.
    "*((long long *)*q)" = retrieve that pointer.

  5. #4

    Join Date
    Jan 2012
    Posts
    27

    Default

    The answer will be -17, Lemme give explanation (Though I'm not C coder ) :

    void ***q=malloc(8); // not valid in other lang'es , C++ prohibits this converting void* to void***

    *q=q; //changes the values of above alocated bytes (sizeof(void**)) to address of q

    *((long long *)*q)=0x012345678abcdef; //some what cycle pointers, *q will result in address of q, dereferencing it is same as bytes (sizeof(long long*)) chunk allocated, this will assign value 0x78abcdef at same time overflowing the 4 byte memory chunk I guess

    (int)*((char *)q) // this will print 1st byte value which is -17

    But seriously any company will throw you out if you'll write this type of code :D
    Last edited by Mr_Anubis; January 26th, 2012 at 11:13 AM.

  6. #5

    Join Date
    Jan 2012
    Location
    USA
    Posts
    8

    Default

    correct lol

Similar Threads

  1. from this trackers where you can get invites
    By bogbog in forum BitTorrent
    Replies: 4
    Last Post: May 23rd, 2010, 10:05 AM
  2. Want to download at work? Now you can!
    By Sky_ in forum BitTorrent Discussion
    Replies: 7
    Last Post: October 11th, 2009, 07:36 PM
  3. Help with utorrent and multiple pcs, If you can
    By James3kgtVR4 in forum Help
    Replies: 4
    Last Post: October 5th, 2009, 02:51 PM
  4. Drum and Bass MP3's Help me if you can!
    By Jamescann in forum Music
    Replies: 10
    Last Post: August 4th, 2009, 05:01 PM
  5. TTi - help if you can!
    By rudam.meredez in forum Completed Requests
    Replies: 2
    Last Post: March 29th, 2009, 07:33 AM

Tags for this Thread

Posting Permissions

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