Click here to Skip to main content
13,150,867 members (41,749 online)
Rate this:
Please Sign up or sign in to vote.
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.
Posted 13-Feb-13 19:13pm
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.
Member 9586495 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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170924.2 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100