Advertisement

LPCSTR's - how do ya use 'em?

Started by March 09, 2000 03:45 PM
4 comments, last by BeanDog 24 years, 9 months ago
I am trying to piece together my own font routines. Very simple, as a matter of fact. My question is, if you pass in an LPCSTR, how do you read the characters from it? Just like this: void bPrint(LPDIRECTDRAWSURFACE7 &Font, LPDIRECTDRAWSURFACE7 &Dest, LPCSTR sOutput, int len) I want to read it one char at a time into a temporary char variable. How do I do this?
LPCSTR is defined as const char FAR*
so you could just index into the character array.
Play free Java games at: www.infinitepixels.com
Advertisement
Perhaps you do not fully understand my ignorance...

A little source code would help.

Thanks a lot. (not sarcastic)
You use them just as you would use a char* argument:

void bPrint(LPDIRECTDRAWSURFACE7 &Font, LPDIRECTDRAWSURFACE7 &Dest, LPCSTR sOutput, int len)
{
char c;

// Access the characters in sOutput
c = sOutput[0];
}


So you don''t need any dereference operator or whatever nonsense to get it? just use it like a normal array?

By the way, thanks a lot guys.
Yes. LPCSTR stands for "Long Pointer to Constant String" (I think). constant strings are, of course, simply char arrays, which can be represented by char* 's. Since the string is const, you can't change any of the data, but can access it for reading the same way you would normally.

No reason to dereference anything, although, technically, using the subsript notation (ex: sOutput[0]) implies dereferencing after adding an offset to the original pointer value.


*oof*

/*woo hoo! I notice i'm a fanatic now! I'd like to thank the beatles, and my parents, my dog sparky...*/

Edited by - Oofnish on 3/10/00 11:31:41 AM
*oof*

This topic is closed to new replies.

Advertisement