Thread: hello pointers

  1. #1
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751

    hello pointers

    I just started learning pointers.
    I'm going to bed now.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  2. #2
    ---
    Join Date
    May 2004
    Posts
    1,379
    ...ok?

  3. #3
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Rule number 1 to follow when learning pointers: keep headache medicine in arms reach at all times

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Is that

    char *pointer = "hello";
    or
    char *hello = "pointer";
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    ---
    Join Date
    May 2004
    Posts
    1,379
    no its
    char *string = "hello pointers";

    by the way. Binky will help you out with pointers.
    http://cslibrary.stanford.edu/104

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Rule number 1 to follow when learning pointers: keep headache medicine in arms reach at all times
    The who and the what now? Pointers are very simple, people just think too hard when learning them and make things more difficult on themselves. The headache medicine is needed later when you start debugging a pointer related problem in a large application.
    My best code is written with the delete key.

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    According to the first post, it's...
    Code:
    bed *caroundw5h;
    Quzah.
    Hope is the first step on the road to disappointment.

  8. #8
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    I think pointers are only difficult to people who started on some higher level thing such as VB. Many of us started on C so we got them right up front.

    And yes as prelude said, the real fun is when you have some bug where you overwrite some piece of memory because you did something stupid with a pointer. If the debugger doesn't catch it immediately, you're in for a wild ride.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  9. #9
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Binky is awsome!

    gg

  10. #10
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    Quote Originally Posted by quzah
    According to the first post, it's...
    Code:
    bed *caroundw5h;
    Quzah.

    WTF
    I understood everything up till your post quzah. jokes. a pointer of type bed whose address value is attached to variable caroundw5h? right? Honestly, pointers don't seem that hard. I think It might be all the preface ppl make about it being the most confusing thing in C and so you kinda psyche yourself out.

    As far as i'm cocerned right now. a pointer points to an object in memory - more specifically the addy's value, and seemingly you can manipulate that somehow is that right?

    C doesn't necessarily have a string data type so it uses pointers for that sometimes like
    Code:
    char *string = "caroundw5h";
    but what can you really do with pointers. What are there true powers? how powerful are they? ppl make a big deal about them. Why? when you get down to manipulating addresses and such what can you really do?
    Last edited by caroundw5h; 06-23-2004 at 10:00 AM.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  11. #11
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >a pointer points to an object in memory - more specifically the addy's value, and seemingly you can manipulate that somehow is that right?
    A pointer is just another variable. The data it holds is an address, and you can either work with the pointer like any other variable, or dereference the pointer and work with the data at that address. This dual nature is what confuses people the most.

    >What are there true powers?
    There are a number of things that pointers can do, but the most obvious is linked data structures. Writing a dynamic linked data structure without pointers is tedious and not as intuitive.
    My best code is written with the delete key.

  12. #12
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    thanks prelude. that actually gives me a little more understanding.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  13. #13
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    I thought pointers were pretty easy, but then of course they can get complicated.
    Code:
    char (*(*x[3])())[5]; 
    char (*(*x())[])();

  14. #14
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by caroundw5h
    WTF
    I understood everything up till your post quzah. jokes. a pointer of type bed whose address value is attached to variable caroundw5h? right?
    Read it like you'd read a pointer declaration:

    caroundw5h is a pointer to a bed. Now turn it into a sentence. Caroundw5h is pointed to their bed. Caroundw5h is headed to bed. Bah. Nevermind. It's not a joke if you have to explain it.

    Quzah.
    Hope is the first step on the road to disappointment.

  15. #15
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    Quote Originally Posted by quzah
    Read it like you'd read a pointer declaration:

    caroundw5h is a pointer to a bed. Now turn it into a sentence. Caroundw5h is pointed to their bed. Caroundw5h is headed to bed. Bah. Nevermind. It's not a joke if you have to explain it.

    Quzah.


    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 AM
  2. function pointers
    By benhaldor in forum C Programming
    Replies: 4
    Last Post: 08-19-2007, 10:56 AM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 01:18 PM