Click here to Skip to main content
14,766,644 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,
I am MFC(VC++) programmer :-).
So while dealing with string i used CString class that provide me all string manupulation routines.So strong class having all thing that needed to manupulate string. :-).
But now my software architecture restrict me on only C++. anable to used MFC library,and i cant used even ,
std::string. :-(
so my all string manupulation should using char*.
So, please provide me hint,code,link or any type of help that helps me to manupulate string using following functions,
so how can used,
char* StringRight(char* ParamString,int Index)
          //Need ccde to do this.
char* LeftString(char* ParamString,int Index)
          //Need ccde to do this.
char* MidString(char* ParamString,int Index,int count)
          //Need ccde to do this.
int FindString(char* ParamString,char * FindString)
          //Need ccde to do this.
int StringLength(char* ParamString)
          //Need ccde to do this.
bool StringReplace(char* ParamString,char* ReplaceString)
          //Need ccde to do this.
bool StringDelete(char* ParamString,int count)
          //Need ccde to do this.
//and for insert ,concat etc.

all helps are greatly appreaciates.
Mohibur Rashid 14-Feb-13 4:51am
Question: why you cant use std library?
Maciej Los 14-Feb-13 5:39am
Good question! My virtual 5!
Emilio Garavaglia 14-Feb-13 5:52am
This is a non-sense: if you are restricted to only C++ you can use std::string being std::string part of the C++ spec, otherwinse you are not using C++ (in proper sense).

Unless the real problem is the use of dynamic memory, but in that case the way you prototyped wont help, since
- you still need it and ...
- you will be in trouble managing it:

In general, returning a char* is not a good C++ practice, sine it is not clear who got the memory it points to and who will be in charge to release it. Your functions -as they are now- are potential sources of memory leaks.

Much better can be writing yourself a class that wraps that pointer and keep managing the memory itself.

But OOPS... that will be nothing more than another std::string or CString or whatever.
So what's the clue, here?
Coder Block 14-Feb-13 6:18am
guys i totally deals with.o files .increasing even 1 bit in .o file matter lots for me.
usage of std::string increase my .o file size increadably.
sja63 14-Feb-13 8:04am
Brian W. Kernighan, Dennis M. Ritchie: The C Programming Language. 2. Auflage. Prentice Hall, Englewood Cliffs, N.J. 1988, ISBN 0131103628.
Stefan_Lang 15-Feb-13 5:21am
If file size is so important to you, then you should mention that in your posting. moreover, since a couple of bits or bytes or even megabytes shouldn't matter on a Desktop PC, you are obviously working on an application for a different, much more limited target system. And it probably has a different OS. That is very important information without which we cannot offer you any useful advice!

Please add that information to your query.

1 solution

You could make use of the C-library string manipulation routines[^].
Coder Block 14-Feb-13 6:19am
thanks Richards but i already go throught this but cant find the solution.
Richard MacCutchan 14-Feb-13 6:43am
What solution? I am suggesting you use those functions in the code that you have to write. I don't really understand why you cannot use MFC or STL to solve this problem.
Coder Block 14-Feb-13 7:25am
.o created by mfc is much greater in size than normal c++ compliler.
Richard MacCutchan 14-Feb-13 7:36am
What do you expect, and why is that a problem?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900