how to convert a 'const char *' to 'char *' in vc++

文章推薦指數: 80 %
投票人數:10人

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



請為這篇文章評分?