character pointer clarification

This is a discussion on character pointer clarification within the C Programming forums, part of the General Programming Boards category; Hi! If I make a pointer to an array of characters like this: char *text[50]; Will that be a pointer ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    12

    character pointer clarification

    Hi! If I make a pointer to an array of characters like this:

    char *text[50];

    Will that be a pointer to a string that is 49 characters long? I want to make a list of words, where each word is at most 49 characters long.

    And if what I did was correct, how would I access each different word? Should I make another pointer that points to text and increment it? And should that new pointer also be declared with the 50 tacked at the end?

    Thanks.
    Last edited by theweirdo; 01-28-2002 at 05:35 PM.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >char *text[50];
    This is an array of 50 pointers to char. It's similar to a 2D array.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    752
    Hmm...
    char * text[50]
    is an array of 50 char *s.

    Maybe this is what you need?
    typedef char fiftycharstring[50];
    fiftycharstring * text;
    Which is a pointer to a string of length 50.
    Callou collei we'll code the way
    Of prime numbers and pings!

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    12
    Yes, that is exactly what I need, thanks so much.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 04:23 AM
  2. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM
  4. mygets
    By Dave_Sinkula in forum C Programming
    Replies: 6
    Last Post: 03-23-2003, 06:23 PM
  5. Character pointer problem.
    By kiss_psycho in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 01:49 AM

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