Re: char array and pointer?

From: TomekG (tomgas_at_cntk.pl)
Date: 08/13/04


Date: Fri, 13 Aug 2004 13:30:19 +0200

Hi, Rola
LPTSTR == const char * "A 32-bit pointer to a character string that is
portable for Unicode and DBCSYou function returning pointer to string ,no
value char",msdn
LPTSTR NaVelke(TCHAR str[])
{
    LPTSTR strTemp;
    strTemp = ::CharUpper((LPTSTR)str);
    return (strTemp + 2);
}

Function returning char (no pointer)
CHAR NaVelkeChar(TCHAR str[])
{
    LPTSTR strTemp;
    strTemp = ::CharUpper((LPTSTR)str);
    return *(strTemp + 2);
}

Modify:
void Function1a()
{
    TCHAR buff[] = "abcdefgh";
    LPTSTR str="\0\0"; //str must ended by 0
    *(str+0) = NaVelke(buff);
    MessageBox(str, NULL, MB_OK);// you must construct null terminating
                                                           //string str only
for MessageBox
}



Relevant Pages

  • Re: confusion when comparing char * with a string literal
    ... char *, and array. ... when I try to comapare 'str' with "today", ... points it to somewhere in memory, or to malloc memory to it before we ... But what ur program does is it makes a pointer variable, ...
    (comp.lang.c)
  • Re: char array and pointer?
    ... It compiles but after that the error msg saying that memory ... I used function returning char and modified ... > portable for Unicode and DBCSYou function returning pointer to string,no ... > LPTSTR strTemp; ...
    (microsoft.public.vc.language)
  • Re: confusion when comparing char * with a string literal
    ... char *, and array. ... Include string.h to get the prototype for strtok. ... printf("%s", str); ... You're passing a null pointer to printf and telling it to follow ...
    (comp.lang.c)
  • Re: How does this c - code work
    ... str is an array of characters (this is not the same as a char pointer, ... When an array is used in an expression, it evaluates to a pointer to its ... fine, stris a char *, which goes fine with the %s). ...
    (comp.programming)
  • Re: confusion when comparing char * with a string literal
    ... char *, and array. ... when I try to comapare 'str' with "today", ... Exactly speaking, I know that 'str' is a 4 byte pointer of char type, ... warning: assignment makes pointer from integer without a cast ...
    (comp.lang.c)