Re: Doubt about array's name
- From: Ofloo <info@xxxxxxxxx>
- Date: Wed, 30 Apr 2008 07:34:01 -0700 (PDT)
On 30 apr, 15:34, nembo kid <u...@xxxxxxxxxxxxx> wrote:
In the following function, s shouldn't be a pointer costant (array's name)?
So why it is legal its increment? Thanks in advance.
/* Code starts here */
void chartobyte (char *s) {
while (s!=0) {
printf ("%d", *s);
s++;}
/* Code ends here */
From what i understood from arrays is that array[0] == *array andarray[1] == array++; *array .. and so forth if the predefined size of
the pointer is 4bytes array++ will go to the next 4bytes in memory ..
basicly pointers are arrays and arrays are pointers, .. the other
thing should work also the other way arround, ..
#include <stdio.h>
#include <string.h>
int main() {
int i;
char *p_str = "mystring";
printf ("%s\n", p_str);
for (i = 0;i < strlen(p_str); i++)
printf ("%c", p_str[i]);
printf ("\n");
return 0;
}
.
- Follow-Ups:
- Re: Doubt about array's name
- From: Keith Thompson
- Re: Doubt about array's name
- References:
- Doubt about array's name
- From: nembo kid
- Doubt about array's name
- Prev by Date: Re: C is best
- Next by Date: Re: Is cast operator unary or binary? How many operands?
- Previous by thread: Re: Doubt about array's name
- Next by thread: Re: Doubt about array's name
- Index(es):
Relevant Pages
|
|