void general pointers

This is a discussion on void general pointers within the C++ Programming forums, part of the General Programming Boards category; Question: If I have a void pointer storing the address of an integer, how would I be able to print ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    4

    Post void general pointers

    Question:

    If I have a void pointer storing the address of an integer, how would I be able to print that integer from the void pointer?

    example:

    Code:
    void main()
    {
    	void *pntr;
    	int x = 7;
    	pntr= &x;
    	printf("%i", ????);
    
    }
    I want to print the 7 using the void pointer, NOT using x anymore. All I can do is get pntr to print the address of x in integer form, but that's the furthest I can get... can anyone else help?

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    printf("%i", *(int*)pntr);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting a swf file in a windows application
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 05-03-2009, 11:29 AM
  2. seg fault at vectornew
    By tytelizgal in forum C Programming
    Replies: 2
    Last Post: 10-25-2008, 01:22 PM
  3. i cannot see the mouse arrow
    By peachchentao in forum C Programming
    Replies: 6
    Last Post: 12-10-2006, 03:14 AM
  4. linked list problem
    By kzar in forum C Programming
    Replies: 8
    Last Post: 02-05-2005, 03:16 PM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 11:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21