Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

BeanDog

LPCSTR's - how do ya use 'em?

This topic is 6825 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
LPCSTR is defined as const char FAR*
so you could just index into the character array.

Share this post


Link to post
Share on other sites
Perhaps you do not fully understand my ignorance...

A little source code would help.

Thanks a lot. (not sarcastic)

Share this post


Link to post
Share on other sites
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];
}


Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!