Results 1 to 3 of 3

Thread: pointers question

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    pointers question

    int *mInt = 5; // Error
    char *mString = "hello!"; //Works

    but..why? is it because the mString is an array of chars?
    i dont get it lol..what is the rule here?
    \m/\m/

  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    int* mInt is a pointer to an int, not an int. So you assign 5 to it, whioch means it is pointing at an int in memory at location 0x00000005, which is illegal.

    char* mString is a pointer to a char, not a char. However, when you assign a string to it like that, that string already has a memory address that is legal.

    Z.

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    yes thats what i though when i started reading ur post lol
    \m/\m/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width