Thread: A pointer to String

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    13

    A pointer to String

    Hi:

    How would I create a pointer to a String in C?

    thanks in advance.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Code:
    char *p = "some string literal";
    A pointer to a string is just a pointer to char that ends up pointing to a sequence of characters in memory ending with nul.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    13
    But how would I create a pointer that will be pointing to a string but it is initialized to null?

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >But how would I create a pointer that will be pointing to a string but it is initialized to null?
    Code:
    char *p = NULL;
    Then later you can point it wherever you'd like.
    My best code is written with the delete key.

  5. #5
    Registered User
    Join Date
    Jun 2003
    Posts
    13

    Talking

    alright...thanks alot!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer to String and Pointer to Char
    By vb.bajpai in forum C Programming
    Replies: 3
    Last Post: 06-15-2007, 03:03 PM
  2. Pointer to array of string and Array of Pointer to String
    By vb.bajpai in forum C Programming
    Replies: 2
    Last Post: 06-15-2007, 06:04 AM
  3. String issues
    By The_professor in forum C++ Programming
    Replies: 7
    Last Post: 06-12-2007, 09:11 AM
  4. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 03:40 AM
  5. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 03:58 PM