Re: char array and pointer?

From: Scott McPhillips [MVP] (org-dot-mvps-at-scottmcp)
Date: 08/13/04


Date: Fri, 13 Aug 2004 06:57:48 -0500

Rola wrote:
> Hi,
>
> Function NaVelke is supposed to convert char array to upper case and then
> return 1 char at a given position.
> here is the code:
>
> LPTSTR NaVelke(TCHAR str[])
> {
> LPTSTR strTemp;
> strTemp = ::CharUpper((LPTSTR)str);
> return (strTemp + 2);
> }

This code does not return 1 char. LPTSTR is a char pointer, not a char.
  (strTemp + 2) is a char pointer, not a char.

-- 
Scott McPhillips [VC++ MVP]


Relevant Pages

  • Re: How is it working? Am I doing it right?
    ... and puts all the lines in a 2d char array for comparison later. ... character or array of characters depending on how you use it. ... here testfunct takes a char pointer so the compiler silently converts word ... The compiler would accept it and when you ran it you would get a buffer ...
    (comp.lang.c)
  • Re: What is wrong with this: *p++=*s++
    ... That's no puzzle at all. ... gives you an array of 80 chars. ... because you're treating 'p' as if it where an char pointer by trying ...
    (comp.lang.c)
  • Re: *** glibc detected *** ./test: realloc(): invalid old size: 0x00007fff49779070 ***
    ... PS any memory leaks in there? ... here allocate just a single char pointer. ...
    (comp.lang.c)
  • Re: BUS ERROR
    ... well *I* didn't intend to say I was getting a bus error ... you are trying to access a four byte integer with say a char ... In this case the char pointer is aligned on a single byte ... may bus error is ia is not correctly aligned for an int ...
    (comp.lang.c)
  • Re: C question
    ... value of the single char that's stored at that address and converted ... treated as if it would be not a char pointer but a pointer to unsigned ... On several non-Intel architectures ... why people have been telling you not to do that but use memcpy() ...
    (comp.lang.c)