Click here to Skip to main content
15,878,748 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Rules for what you can/can't do inside DOC class serialization(loading) routine Pin
Iain Clarke, Warrior Programmer25-Sep-09 21:21
Iain Clarke, Warrior Programmer25-Sep-09 21:21 
QuestionFunction does not return String as wanted Pin
Tomicmanka25-Sep-09 6:26
Tomicmanka25-Sep-09 6:26 
AnswerRe: Function does not return String as wanted Pin
markkuk25-Sep-09 7:05
markkuk25-Sep-09 7:05 
QuestionRe: Function does not return String as wanted Pin
David Crow25-Sep-09 7:51
David Crow25-Sep-09 7:51 
AnswerRe: Function does not return String as wanted Pin
Tomicmanka25-Sep-09 8:47
Tomicmanka25-Sep-09 8:47 
GeneralRe: Function does not return String as wanted Pin
David Crow25-Sep-09 8:57
David Crow25-Sep-09 8:57 
AnswerRe: Function does not return String as wanted Pin
Tomicmanka25-Sep-09 9:28
Tomicmanka25-Sep-09 9:28 
GeneralRe: Function does not return String as wanted Pin
Stuart Dootson26-Sep-09 0:07
professionalStuart Dootson26-Sep-09 0:07 
Tomicmanka wrote:
I just want to know how to write a c++ function that accepts a string as parameter and return a string back to the main() function.


Rather than passing a string by value, you should generally prefer passing a string by reference to minimise copying.

std::string conv_str_to_upper (std::string const& str)
{
   std::string upper;
   // Tell upper how long it's going to end up being, so we can allocate that space all at once
   upper.reserve(str.length());
   // Copy s to upper, but upper-case each character as we go.
   std::transform(s.begin(), s.end(), std::back_inserter(upper), (int (*)(int))&std::toupper);
   return upper;
}


The code for the function is taken from this page[^], which is kind of on your topic.

Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

GeneralRe: Function does not return String as wanted Pin
Tomicmanka26-Sep-09 0:55
Tomicmanka26-Sep-09 0:55 
QuestionHiding and showing CSplitterWnd panes "mistery" Pin
Vaclav_25-Sep-09 6:07
Vaclav_25-Sep-09 6:07 
QuestionConstant Expression Required Pin
nowrocktheworld25-Sep-09 4:49
nowrocktheworld25-Sep-09 4:49 
AnswerRe: Constant Expression Required Pin
Naveen25-Sep-09 4:59
Naveen25-Sep-09 4:59 
GeneralRe: Constant Expression Required Pin
nowrocktheworld25-Sep-09 6:18
nowrocktheworld25-Sep-09 6:18 
AnswerRe: Constant Expression Required Pin
David Crow25-Sep-09 5:40
David Crow25-Sep-09 5:40 
AnswerRe: Constant Expression Required Pin
CPallini25-Sep-09 9:51
mveCPallini25-Sep-09 9:51 
AnswerRe: Constant Expression Required Pin
Iain Clarke, Warrior Programmer25-Sep-09 21:26
Iain Clarke, Warrior Programmer25-Sep-09 21:26 
QuestionSet/get Controls of an Another dialog box [modified] Pin
hrishiS25-Sep-09 4:32
hrishiS25-Sep-09 4:32 
AnswerRe: Set/get Controls of an Another dialog box Pin
David Crow25-Sep-09 5:44
David Crow25-Sep-09 5:44 
QuestionCAPI read certificat etoken Window xp Pin
Member 442420525-Sep-09 4:28
Member 442420525-Sep-09 4:28 
QuestionGetCursorPos failed in Service mode.... Pin
onlyjaypatel25-Sep-09 3:52
onlyjaypatel25-Sep-09 3:52 
AnswerRe: GetCursorPos failed in Service mode.... Pin
«_Superman_»25-Sep-09 16:41
professional«_Superman_»25-Sep-09 16:41 
Questiondoubt in cstring.. Pin
Rakesh525-Sep-09 3:40
Rakesh525-Sep-09 3:40 
QuestionRe: doubt in cstring.. Pin
David Crow25-Sep-09 3:47
David Crow25-Sep-09 3:47 
AnswerRe: doubt in cstring.. Pin
Rakesh525-Sep-09 3:53
Rakesh525-Sep-09 3:53 
AnswerRe: doubt in cstring.. Pin
David Crow25-Sep-09 3:56
David Crow25-Sep-09 3:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.