Re: ansi c
- From: Rachael <rachaelluckett@xxxxxxxxx>
- Date: Wed, 23 Jan 2008 10:10:24 -0800 (PST)
On 23 Jan, 16:58, yqy...@xxxxxxxxxxx wrote:
thanks, it works, but why i must use "*" pointer?
Because the char type only stores single characters, like 'a' or 'b'.
Pointer types store locations in memory.
If you do
char c = 'a';
you are writing into the variable c the value of the character
'a' (which is just a number).
If you do
char * pc = "cazzo";
you are writing into the variable pc (which is a char pointer) the
*location* of the beginning of the string "cazzo", which is stored in
memory somewhere. You are not storing the whole string "cazzo" in pc,
because no single variable (i.e. not an array) in C can store a whole
string.
(Note single quotes for characters and double quotes for string
literals)
.
- Follow-Ups:
- Re: ansi c
- From: santosh
- Re: ansi c
- References:
- ansi c
- From: yqyq22
- Re: ansi c
- From: Jensen Somers
- Re: ansi c
- From: yqyq22
- Re: ansi c
- From: Mark Bluemel
- Re: ansi c
- From: yqyq22
- ansi c
- Prev by Date: Re: When to check the return value of malloc
- Next by Date: Re: When to check the return value of malloc
- Previous by thread: Re: ansi c
- Next by thread: Re: ansi c
- Index(es):
Relevant Pages
|