Input on arrays and pointers

This is a discussion on Input on arrays and pointers within the C Programming forums, part of the General Programming Boards category; Hi everyone I am trying hard reading books and using the internet to better understand pointers, structures and arrays. I ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    115

    Input on arrays and pointers

    Hi everyone I am trying hard reading books and using the internet to better understand pointers, structures and arrays. I posted what I think I know thus far below and would like anyone to correct my mistakes or assumptions thus far. Thanks in advance.

    WHEN USING CHAR POINTERS

    P = ENTIRE STRING

    &P = ADDRESS OF THE POINTER

    *P = 1RST BLOCK OF THE STRING (IN EG BELOW POINTS TO 'T')

    *(P + 2) = 3RD BLOCK OF THE STRING (IN EG BELOW POINTS TO 'i')

    THE POINTER MUST BE INITIALIZED AND VALUES ASSIGNED
    IN A MANNER SUCH AS BELOW:

    char *carl;
    carl = "This is helping me learn";

    ------------------------------------------------------------------------------------------

    WHEN USING INT POINTERS

    P = ADDRESS OF THE CONTENTS P IS POINTING TO (IN EG BELOW ADDRESS OF 500)

    &P = ADDRESS OF THE POINTER ITSELF (INT *P's ADDRESS)

    *P = CONTENTS OF THE POINTER (1 BLOCK OF MEMORY)

    THE POINTER MUST BE INITIALIZED AND VALUES ASSIGNED
    IN A MANNER SUCH AS BELOW:

    int time = 500;

    int *carl2;

    carl2 = &time;

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    carl = "This is helping me learn";
    carl should be declared as const char*

    IN EG BELOW POINTS TO 'i'
    P + 2 - points to 'i'
    *(P+2) evaluates to 'i'
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    115

    Thanks

    Thank you for the feedback. I am starting pointers to structures next so back to the book.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointers and multi dimensional arrays
    By andrea72 in forum C++ Programming
    Replies: 5
    Last Post: 01-23-2007, 03:49 PM
  2. Passing pointers to arrays of char arrays
    By bobthebullet990 in forum C Programming
    Replies: 5
    Last Post: 03-31-2006, 04:31 AM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM
  4. Arrays of pointers (input)
    By tyskater in forum C Programming
    Replies: 10
    Last Post: 12-16-2003, 11:00 PM
  5. Help understanding arrays and pointers
    By James00 in forum C Programming
    Replies: 2
    Last Post: 05-27-2003, 01:41 AM

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