Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Development

Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days.

Reply
 
Thread Tools Display Modes
  #1  
Old 06-05-2002, 04:22 AM
Wiz
Dragon
 
Join Date: Feb 2002
Posts: 583
Default Strings...

What's the EQemu function for selecting certain letters from a string? Doesn't have a substr, as far as I can see, so I was wondering what's being used instead.
Reply With Quote
  #2  
Old 06-08-2002, 06:04 AM
theCoder
Sarnak
 
Join Date: Jan 2002
Posts: 90
Default

You mean from inside of an EQ client? Or from c code? If you mean c code, there's always strstr (man strstr for info) or strchr (man strchr for info). I don't know if someone wrote a specialized string searching function inside the EMU, but it would probably be hard to beat one of the built in functions as far as performance.
Reply With Quote
  #3  
Old 06-08-2002, 10:53 PM
Wiz
Dragon
 
Join Date: Feb 2002
Posts: 583
Default

Yeah, from the C code. Specifically, selecting the "00" etc from an NPC name. I'm trying to cut that off in the GetName() function.

"man"? Sorry, you're dealing with someone with four weeks of C++ experience, heh.
Reply With Quote
  #4  
Old 06-09-2002, 05:33 AM
theCoder
Sarnak
 
Join Date: Jan 2002
Posts: 90
Default

man is a command you can use to find information about various things, from other commands to system calls and more. man is short for manual, but it's only available (AFAIK) on UNIX style systems (Linux, MacOSX, etc).

As far as finding the "00" in a null terminated string, you'll probably want to use strstr. strstr takes two parameters: the string to search and the string to search for. It returns a pointer to the position in the first string where the second string is located (or NULL if it's not found). For example:
Code:
char[256] name = "Some name00";
char* found = strstr(name, "na");
printf("%s\n", found);
Would print out "name00". In this case, found is actually equal to name+5 in terms of pointer math. It can get confusing if you don't understand how pointers work. I'd suggest you find some reference that explains pointers in c/c++.

To better answer your original question, however, if you wanted to delete the "00" in the name above, you would strstr for "00" and if it was found (return value is not NULL), then deference the pointer and set it to '\0' (the null character):
Code:
char* found = strstr(name, "00");
if (found != NULL) *found = '\0';
printf("%s\n", name);
Now it prints out "Some name".

Also, if you do change the data in the string, you should be sure to copy it first or it will change the data in the class (which you probably don't want )

HTH
Reply With Quote
  #5  
Old 06-10-2002, 01:26 AM
Wiz
Dragon
 
Join Date: Feb 2002
Posts: 583
Default

Exactly what I was looking for, thanks a ton!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 11:38 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3