By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,266 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,266 IT Pros & Developers. It's quick & easy.

[HELP] How to remove duplicate char array

P: 4
right now i have gotten all the classes to print out using helpdbg. Now i want to remove the duplicate class names out of an array so i can just print one of each.
This is the output i have.

[HTML]class URopeBeamEmitter;
class AAGP_GameInfo;
class AAGP_Weapon;
class ABaseScope;
class AInfantryHUD;
class UCamEffect_BlurOut;
class URopeBeamEmitter;
class AAGP_GameInfo;
class AAGP_Pawn;
class AAGP_Weapon;
class AAgentController;
class ABaseScope;
class AHumanController;
class AInfantryHUD;
class ALaserProjector;
class UCamEffect_BlurOut;
class UCamEffect_FlashBang;
class URopeBeamEmitter;
class AAGP_Pawn;
class AAgentController;
class AHumanController;
class ALaserProjector;
class UCamEffect_FlashBang;
class AAGP_GameInfo;
class AAGP_Weapon;
class ABaseScope;
class AInfantryHUD;
class UCamEffect_BlurOut;
class URopeBeamEmitter;
class AAGP_Pawn;
class UCamEffect_BlurOut;
class AAGP_Pawn;
class URopeBeamEmitter;
class URopeBeamEmitter;
class AHumanController;
class AAGP_Pawn;
class URopeBeamEmitter;
class AAGP_GameInfo;
class AAGP_Weapon;
class ABaseScope;
class AInfantryHUD;
class UCamEffect_BlurOut;
class URopeBeamEmitter;
class URopeBeamEmitter;
class URopeBeamEmitter;
class AHumanController;
class AAGP_Pawn;
class URopeBeamEmitter;
class UCamEffect_FlashBang;
class AAGP_GameInfo;
class AAGP_Weapon;
class ABaseScope;
class AInfantryHUD;
class UCamEffect_BlurOut;
class URopeBeamEmitter;
class AAGP_Pawn;
class URopeBeamEmitter;
class AAGP_GameInfo;
class AAGP_Weapon;
class ABaseScope;
class AInfantryHUD;
class UCamEffect_BlurOut;
class URopeBeamEmitter;
class AAGP_Pawn;
class AAGP_Pawn;
class AAGP_Pawn;
class AAGP_Pawn;
class URopeBeamEmitter;
class AAGP_Pawn;
class AAGP_Pawn;
class AHumanController;
class AAGP_Pawn;
class AAgentController;
class AHumanController;
class UCamEffect_BlurOut;
class AHumanController;
class AAGP_Pawn;
class AAGP_Weapon;
class AHumanController;
class AHumanController;
class AHumanController;
class UCamEffect_FlashBang;
class AAGP_Pawn;
class AAGP_Pawn;[/HTML]

as you can see many duplicate names. I just need hint or so how to remove them from my array.
Apr 18 '07 #1
Share this Question
Share on Google+
4 Replies


Expert 10K+
P: 11,448
Have a look at a set<string> object. Add all your strings to a set (which
doesn't allow duplicates) and get them back again out of the set<string>

kind regards,

Jos
Apr 18 '07 #2

gpraghuram
Expert 100+
P: 1,275
HI,
if u want to remove the duplicates from the output then you have to use some unix commands.
If u want to remove it inside C++ code then try to push the values into a map(STL) and then print it.

Thanks
Raghuram
Apr 18 '07 #3

P: 86
i thnk set<string> option is much more relevant in this case than maps as thrs only strings here and he is not associatng strings with other type of objects...
Apr 18 '07 #4

P: 4
Thanks for the info. I will most likely try both ways. To see which one is more efficient for my program. I got my output of the class names by cuting the strings from the undecorated names shown below:


[HTML] DWORD dwErr = UnDecorateSymbolName(szName, DLLFunctions, sizeof(DLLFunctions), UNDNAME_COMPLETE);

if(dwErr == 0)
{
dwErr = GetLastError();
TCHAR lpMsgBuf[1000];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), lpMsgBuf, 1000, NULL );
}


if(strstr(DLLFunctions, "::"))
{
strcpy(DLLFunctions + (strstr(DLLFunctions, "::") - DLLFunctions),"\0");
strcpy(DLLFunctions,DLLFunctions + ((strrchr(DLLFunctions,' ') + 1) - DLLFunctions ));
strcpy(ClassName, DLLFunctions);
strcpy(ClassName2, DLLFunctions);

fprintf(HeaderFile, "class %s;\n", ClassName);

}[/HTML]

Now my next step is to get all the correct functions associated with that class in the proper class: though right now its only printing one function in each class instead of all of them



[HTML] fprintf(HeaderFile, "\n");
fprintf(HeaderFile, "//---------------------------------------------------------------------------------\n");
fprintf(HeaderFile, "//class %s.%s Generated from DLL and U file\n", argv[1], ClassName );
fprintf(HeaderFile, "//---------------------------------------------------------------------------------\n");

fprintf(HeaderFile, "\nclass %s_API %s : public ?\n{\n", cpyargv, ClassName);

fprintf(HeaderFile, "\t%s;\n", DLLFunctions);


fprintf(HeaderFile, "};\n\n");[/HTML]


heres the example of the print out:

[HTML]class AGP_API AAGP_Pawn : public ?
{
public: virtual void __thiscall AAGP_Pawn::stepUp(class FVector,class FVector,class FVector,struct FCheckResult &);
};[/HTML]

as for the ? for the parent class will have to be done later when i get the info from the data already contain in other files.
Apr 22 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.