how to convert a 'const char *' to 'char *' in vc++
文章推薦指數: 80 %
You can use casting operators to do so. ... const char *ask = "so easy"; char *temp = NULL; temp = (char *)ask; try this.. ... But if it const for a good reason ... 470,814Members|1,128OnlineSigninJoinNowHomePostsTopicsMembersFAQhome>topics>c/c++>questions > howtoconverta'constchar*'to'char*'invc++ Postyourquestiontoacommunityof470,814developers. It'squick&easy.howtoconverta'constchar*'to'char*'invc++jsl7 howtoconverta'constchar*'to'char*'invc++ May2'07 #1FollowPostReply412730svlsr2000181 Expert100+ Youcanusecastingoperatorstodoso. May2'07 #2replyxoinki110 100+ constchar *ask="soeasy"; char *temp=NULL; temp=(char*)ask; trythis.. Xoinki May2'07 #3replyBanfa9,065 ExpertMod8TB Butifitconstforagoodreasonthenyouwillneedtocreateabufferofyourownandcopyitthere. May2'07 #4replyjsl7 constchar *ask="soeasy"; char *temp=NULL; temp=(char*)ask; trythis.. Xoinki thankyouXoinki,ithassolvedmyproblem May3'07 #5reply Message CancelChangesPostyourreplySignintopostyourreplyorSignupforafreeaccount. PostReplySimilartopicsC/C++constqualifierandVC6.0 8posts views ThreadbySergeyTolstov| lastpost:by C/C++cannotconvertchar**toconstchar** 5posts views ThreadbyBradMoore| lastpost:by C/C++Convertachararraytoamanagedsystemstring 27posts views ThreadbyTrep| lastpost:by C/C++errorC2440:'return':cannotconvertfrom'constchar*'to'constunsignedshort*'Typespointedtoareunrelated;conversionrequiresreinterpret_cast,C-stylecastorfunction-stylecast 2posts views ThreadbyAbhijitBhadra| lastpost:by .NETFrameworkConvertSystem::String*tochar* 15posts views ThreadbyYifan| lastpost:by C/C++errorC2664:'strcpy':cannotconvertparameter2from'char'to'constchar*' 3posts views Threadbykaizen| lastpost:by C/C++ConvertC++stringstoaC-stylestring(char*)inVC++6.0. 1post views ThreadbyTDK02| lastpost:by C/C++VC++errorC2662:cannonconvert'this'pointer... 10posts views Threadbydorkrawk| lastpost:by .NETFrameworkHowtoconvertmanagedclasstounmanagedchar*invc++.net 2posts views Threadbyselvialagar| lastpost:by Ruby/RubyonRailsSending&TestingEmailswithRuby reply views ThreadbyAlexandraMT| lastpost:by MobileDevelopmentBuildYourFirstAppThroughMicrosoftXamarin.Forms reply views Threadbyprepawan| lastpost:by C#/CSharpKnapsack0-1C#binary&rosettacode&WE 1post views ThreadbyDANILIN| lastpost:by GeneralIntegratepositioningtechnologytodealwiththeapplicationofIoTfragmentationscenarios reply views Threadbytracyyun| lastpost:by General10JavaScriptframeworksworthlearningin2022 reply views ThreadbyMarkDoronin| lastpost:by PythonNeedtofindlastdateofaRecurrencePatterninPython reply views Threadbyxykovyci| lastpost:by GeneralBinarySearchDictionary reply views Threadbymihailmihai484| lastpost:by APIsArethereanyexistingAPIsforintegratingChatintoaniOSorAndroidapp? reply views Threadbypatriciajames| lastpost:by VisualBasic4/5/6HowtoremovelastcharactersofStringiftheycontain"" 1post views ThreadbyDönerbude| lastpost:by Byusingthissite,youagreetoourPrivacyPolicyandTermsofUse. Ok
延伸文章資訊
- 1const char - C++ Forum
- 2const char * as a function parameter in C++ - Stack Overflow
- 3Difference between char* and const char*? - Stack Overflow
- 4[C] 每天來點字串用法(3) - from const char* to char*
由 const char* 轉成 char*. 有時候可能在將字串傳入函式時,會出現以下錯誤: error: invalid conversion from 'const char*' to '...
- 5Difference between const char *p, char * const p and const ...
1. const char *ptr : This is a pointer to a constant character. You cannot change the value point...