Re: char array and pointer?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: muchan (usenet_at_usenet.usenet)
Date: 08/13/04


Date: Fri, 13 Aug 2004 11:56:48 +0200

Rola wrote:

> Hi Tomek,
>
> thank you for your advice, anyway this returns not only one char but all the
> chars from a given pos to the end of array. Am I doing something wrong?
>
> Rola
>
> "TomekG" <tomgas@cntk.pl> wrote in message
> news:O%23saCURgEHA.140@TK2MSFTNGP12.phx.gbl...
>
>>int pos;
>>*(array+pos) => value array[pos]
>>

Probably you missed the presence of '*'.

Here (array+pos) is a pointer to a character, that hold the address.
It may be used as holder of the address, which starts the string,
(that is terminated with char '\0' )

*(array+pos) is the content of the address, pointed by that pointer.
It is one char.

To clear the basic confusion, you should read an introductory text
about C and C++'s pointer, array, and general concept of "address".

muchan



Relevant Pages

  • Re: Problem with va_ macros and arrays of arrays
    ... > the arrays passed to a ... > specific char, somewhat similar to what the standard function ... that with an array of struct, or possibly a pointer to a dynamic array ... > As I'm still a beginner in C without a copy of the standard I ...
    (comp.lang.c)
  • Re: Difference between Char* ptr and char arrCh []
    ... I have a few queries regarding array of characters using array ... notation and pointer notation. ... Is there a difference in storage of global char* and char* inside ...
    (comp.lang.c)
  • Re: char **argv & char *argv[]
    ... "pointer to pointer to char". ... >> pointer)) pointing to the first element of an array. ... so we have to start adding more context. ... type "pointer to char", rather than "array MISSING_SIZE of char". ...
    (comp.lang.c)
  • Re: Returning pointer to array problem II
    ... Iam trying to make program were I enter string and serach char. ... and funktion prints out witch position char is found this is done if funktion serach_char. ... so far all good what I want do next is: return, from funktion, pointer value to array were positions is stored. ...
    (comp.lang.c)
  • Re: Simple question on Pointers
    ... int main ... It stores 12 char and only 12 ... pointer to the first element of the array with type pointer to element ...
    (microsoft.public.vc.language)