whats the difference?

This is a discussion on whats the difference? within the C Programming forums, part of the General Programming Boards category; please, whats the difference between char* name; and char name; thanx!...

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

    whats the difference?

    please, whats the difference between

    char* name;

    and

    char name;

    thanx!

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826

    Re: whats the difference?

    Originally posted by phptech
    please, whats the difference between

    char* name;

    and

    char name;

    thanx!
    You really should just continue your old thread. That being said, one is a pointer, one is a single character.

    * deontes a pointer. This means that the variable itself doesn't have space allocated to it* but rather, it is used to point to another variable. (Hence the name 'pointer'.)

    *The only space allocated there is for the actual pointer itself. You assign pointers the addresses of other variables, not actual data.

    If you've got a C book, go read up on pointers. If not, read the FAQ.

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

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    76
    char* represents a pointer to char, which is a data type that's usually one byte long. This pointer, unless it's allocated or explicitly set, points to memory that's undefined.

    char contains only a single variable of the char type.

    In holding character strings, you usually define a char array that can hold the desired maximum amount:

    Code:
    char name[200];

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Review required for program of date difference
    By chottachatri in forum C Programming
    Replies: 6
    Last Post: 10-31-2008, 11:46 AM
  2. Difference Equations / Recurrence Relations
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-05-2007, 10:26 AM
  3. What's the difference between var++ and ++var
    By ulillillia in forum C Programming
    Replies: 6
    Last Post: 05-31-2007, 02:27 AM
  4. how to get difference of digits
    By Leeman_s in forum C++ Programming
    Replies: 5
    Last Post: 12-20-2001, 07:32 PM
  5. What is the Difference between ANSI C and non-ANSI C ?
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-24-2001, 05:55 AM

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