A simple question

This is a discussion on A simple question within the C++ Programming forums, part of the General Programming Boards category; Hi, What does the "*" does when placed after a type? For example, char* myvar; Plus, anyone know of any ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    51

    A simple question

    Hi,

    What does the "*" does when placed after a type?

    For example,

    char* myvar;

    Plus, anyone know of any good c++ reference sites?

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    11
    it is a pointer. it creates an object that points to another object. it has no real value.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    51
    What is the difference between:

    chr* myvar

    and

    chr *myvar ...

  4. #4
    Registered User matheo917's Avatar
    Join Date
    Sep 2001
    Posts
    279
    there's no difference.....

    compiler knows what you're doing in this case so it doesn't matter how u space out your code....

    (pointer) is designed to hold a memeory address.

    Regards,
    matheo917

  5. #5
    Unregistered
    Guest

    no point

    like he said theres really no point to it.. but just to tell you.. when you do

    int *variable;

    that declares a pointer like he said (it points to the memory address) now try this declare another variable and have it point to it.

    int varone;
    int *variable;

    variable = &varone;
    cout << variable;

    take a look at what you get!

  6. #6
    Registered User
    Join Date
    Mar 2002
    Posts
    203
    like they said, there isn't a difference, but there is one important fact you need to remember about where the * is placed: before the variable name of each pointer being defined.

    char* x, y;
    x will be a pointer, yet y will be just a char
    if you wanted to create 2 pointers it would look like this
    char* x, *y;
    both x and y are now pointers of type char

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple question regarding variables
    By Flakster in forum C++ Programming
    Replies: 10
    Last Post: 05-18-2005, 09:10 PM
  2. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-21-2005, 12:41 AM
  3. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  4. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM
  5. simple fgets question
    By theweirdo in forum C Programming
    Replies: 7
    Last Post: 01-27-2002, 06:58 PM

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