Like Tree3Likes
  • 3 Post By phantomotap

hi ,some questions

This is a discussion on hi ,some questions within the C++ Programming forums, part of the General Programming Boards category; hi guys, I have some questions about pointers and other codes. Is it necessary that we must initialize a pointer? ...

  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
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,714
    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
    4,280
    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, 08:44 AM
  4. A few questions
    By Cell in forum C Programming
    Replies: 7
    Last Post: 01-31-2009, 08:43 AM
  5. Two Questions (They never end... -,-)
    By Blackroot in forum C++ Programming
    Replies: 7
    Last Post: 01-16-2006, 01:06 PM

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