String content within " "

How to use the content of a string variable within " ".

eg.
  int testfound = fd.find("From user argv[1]");
----
simply I need the argument 1 to be substituted there. Is there any escape seq. like that...

any help will be appreciated.
--begin


beginAsked:
Who is Participating?
 
inprasConnect With a Mentor Commented:
fd.find???
what is fd?
0
 
inprasCommented:
Sorry reject I was about to make it comment
hope U won't mind for this
0
 
beginAuthor Commented:
fd is a string which contains around 50 characters.
--begin
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
inprasCommented:
string U mean is it a character array ? or MFC CString?
0
 
inprasCommented:
pu the declaration of fd here Pl
0
 
inprasCommented:
if str is character array then use

char str[50];
strcpy(str, "From user ");
strcat(str, argv[1]);
fd.find(str);

Hope this helps
0
 
mikeblasCommented:
Just make sure that argv[] is 39 characters long, or less.

..B ekiM
0
 
beginAuthor Commented:
thanks to inpras.
0
 
jasonclarkeCommented:
it looks as if you are using the standard library string (good thing too, much less error prone), in which case you can just do:

int pos = fd.find(string("From user ") + argv[1]);

For more complicated substitutions you can use the stringstream class.
0
 
beginAuthor Commented:
thanks jasindarke, it worked pretty well.
--begin
0
 
beginAuthor Commented:
thanks jasondarke, it worked pretty well.
--begin
0
 
jasonclarkeCommented:
unfortunately you accepted someone elses answer, but glad it worked anyway.
0
 
beginAuthor Commented:
It seems you have assumed that from my typographical error, that i have accepted someone else's answer, but its not the truth. actually i have once again asked a typical question related to the first one but with a minimal change. hope i have graded your answer. post me if you have any comments. sorry for your feelings..
--begin
0
All Courses

From novice to tech pro — start learning today.