Thread: hi ,some questions

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    96

    hi ,some questions

    hi guys,

    I have some questions about pointers and other codes.

    Is it necessary that we must initialize a pointer?

    if we have a code as:

    1)char *name;
    2)int *GetInt();

    In 1st line, is the name being used as a pointer which is pointing to the data type "char"?

    In 2nd line, what does the "*" show in this function of GetInt()?

    I hope my questions are clear

    Thanks
    Last edited by student111; 06-04-2012 at 03:01 PM.

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    In 1st line, is the name being used as a pointer which is pointing to the data type "char"?
    Yes. It is impossible to know without any context whether name points to a single char or the first element of an array of char, though. Any data type pointer can point to a single object or an array of objects.

    In 2nd line, what does the "*" show in this function of GetInt()?
    It is part of the return type and signifies that a pointer is returned.

  3. #3
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    You know, you have started a lot of threads with the form "I have questions with easily searchable answers.".

    You apparently know enough about the syntax to know that this is a "pointer" situation. Why don't you start with that?

    Have you read a book about programming yet? (No, you haven't. Please don't say you have.)

    You need to read a programming book and do the exercises.

    You could, theoretically, piece together a working programming knowledge a few bits and pieces at a time. But why would you? You are doing yourself a disservice with this approach. Get yourself a good book and work through it. (Do the exercises.)

    Soma

  4. #4
    Registered User
    Join Date
    May 2012
    Posts
    71
    Reading tutorials is somewhat like studing, who loves it?
    Asking a humans to answer is more plesure for sure and less work. Anyway i agree on 100% with Soma

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C questions
    By malvado in forum General Discussions
    Replies: 33
    Last Post: 05-19-2011, 05:14 AM
  2. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  3. I have some questions :(
    By geekrockergal in forum C Programming
    Replies: 19
    Last Post: 02-01-2009, 09:44 AM
  4. A few questions
    By Cell in forum C Programming
    Replies: 7
    Last Post: 01-31-2009, 09:43 AM
  5. Two Questions (They never end... -,-)
    By Blackroot in forum C++ Programming
    Replies: 7
    Last Post: 01-16-2006, 02:06 PM