Thread: Silly pointer questions

  1. #1
    Registered User
    Join Date
    Jun 2015
    Posts
    2

    Silly pointer questions

    Hello. Learner here. I don't have access to many books and hardly get any internet connection. So making the most of this rare chance to understand few tricky concepts .Please help

    I am aware of simple pointers.
    int *ptr;

    But I don't understand what these are?

    1. int* ptr
    2. ptr*
    3. void*
    4. void (*function)(void)
    5. *((int*)ptr)


    please explain in simple English and if possible example.

  2. #2
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    This looks like it might be an assignment (see the homework policy).

    Why don't you explain what you think each of those things are (based on what you know already), and we'll give you advice based on that.

  3. #3
    Registered User
    Join Date
    Jun 2015
    Posts
    2
    Mr Einstein.This is not homework.
    Not everyone born with silver spoon. I had to cycle an hour to get to an internet cafe where there is current only for three hour a day,and to see your valuable contribution to my question.why don't people like you come to my country and see how people struggle
    to get basic aminities like books, electricity,computer or even a pen and paper.
    I will find my answers and I dont want any help from u.Thank you

  4. #4
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Well, be that as it may, it would help you more in the long run to first hear what you think each one of those are.

    If you don't know what any of them are, I'll give you the first one for free.

    Code:
    int *ptr = 0;
    We're creating a variable called ptr and initializing it to 0.

    ptr is a pointer to an int. This means that like all pointers, ptr stores an address in memory (which we're initializing to 0) and the type of memory it's addressing is an integer.

  5. #5
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Quote Originally Posted by sillyquestion4u View Post
    Mr Einstein.This is not homework.
    Regardless of where the question came from, it is expected that you show some effort in trying to understand the concepts you are asking about. That is why I suggested you explain what you think each one of those statements do, so we could help you understand them better.

    Quote Originally Posted by sillyquestion4u View Post
    Not everyone born with silver spoon. I had to cycle an hour to get to an internet cafe where there is current only for three hour a day,and to see your valuable contribution to my question.
    If my response motivated you to research these things a little bit more, and respond with what you understood of them, then you would have gained a little more knowledge about them on your own (more so than being spoon-fed the answers). That is where the value of my post potentially lies.

    Quote Originally Posted by sillyquestion4u View Post
    I will find my answers and I dont want any help from u.Thank you
    It's obvious you don't want help, since you wasted the precious little internet time you have to whine instead of explaining what you know of the given material. You got those code snippets from somewhere - it stands to reason that same source might also provide some explanation of them.

    I personally am still willing to help, but as I said, I would need to see some effort on your part.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer questions
    By johnpuppa in forum C Programming
    Replies: 16
    Last Post: 07-29-2014, 02:19 PM
  2. Pointer Questions
    By tgrieger in forum C Programming
    Replies: 4
    Last Post: 04-09-2011, 10:14 PM
  3. Two Pointer Questions
    By chris.r in forum C Programming
    Replies: 13
    Last Post: 06-04-2010, 09:40 PM
  4. noob silly pointer? question
    By darin722 in forum C++ Programming
    Replies: 2
    Last Post: 06-13-2009, 06:58 AM
  5. Pointer questions
    By 1rwhites in forum C Programming
    Replies: 1
    Last Post: 10-20-2005, 09:55 AM

Tags for this Thread