Error C2664 String
Contents |
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community
Error C2664 Cannot Convert Parameter
Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers error c2664 cannot convert parameter 1 from Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected error c2664 in c++ in 1 second. C/C++ Building Reference C/C++ Build Errors Compiler Errors C2600 Through C2699 Compiler Errors C2600 Through C2699 Compiler Error C2664 Compiler Error C2664 Compiler
Error C2664 Lpcwstr
Error C2664 Compiler Error C2600 Compiler Error C2601 Compiler Error C2602 Compiler Error C2603 Compiler Error C2605 Compiler Error C2611 Compiler Error C2612 Compiler Error C2613 Compiler Error C2614 Compiler Error C2616 Compiler Error C2617 Compiler Error C2619 Compiler Error C2624 Compiler Error C2626 Compiler Error C2627 Compiler Error C2628 Compiler Error C2630 Compiler
Error C2664 Cannot Convert Argument
Error C2632 Compiler Error C2633 Compiler Error C2634 Compiler Error C2635 Compiler Error C2636 Compiler Error C2637 Compiler Error C2638 Compiler Error C2640 Compiler Error C2645 Compiler Error C2646 Compiler Error C2647 Compiler Error C2648 Compiler Error C2649 Compiler Error C2650 Compiler Error C2651 Compiler Error C2652 Compiler Error C2653 Compiler Error C2654 Compiler Error C2655 Compiler Error C2656 Compiler Error C2657 Compiler Error C2658 Compiler Error C2659 Compiler Error C2660 Compiler Error C2661 Compiler Error C2662 Compiler Error C2663 Compiler Error C2664 Compiler Error C2665 Compiler Error C2666 Compiler Error C2667 Compiler Error C2668 Compiler Error C2669 Compiler Error C2670 Compiler Error C2671 Compiler Error C2673 Compiler Error C2674 Compiler Error C2675 Compiler Error C2676 Compiler Error C2677 Compiler Error C2678 Compiler Error C2679 Compiler Error C2680 Compiler Error C2681 Compiler Error C2682 Compiler Error C2683 Compiler Error C2687 Compiler Error C2688 Compiler Error C2689 Compiler Error C2690 Compiler Error C2691 Compiler Error C2692 Compiler Error C2
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack error c2664 cannot convert parameter from const char to lpcwstr Overflow the company Business Learn more about hiring developers or posting ads with us
Mfc Error C2664
Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community error c2664 cannot convert argument 1 from of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up VS error C2664 (return string from a function) C++ up vote 0 down vote favorite I'm https://msdn.microsoft.com/en-us/library/s5b150wd.aspx sure this was answered somewhere on the site but can not find it... I'm writing under VS10 in C++. I'm writing a class that holds details of a student. One of the members is string studentName[30]; There should be a function that returns this string on request, this could be done using traditional C strings and a pointer however I would like to use C++ strings. My get function looks like so: http://stackoverflow.com/questions/23845075/vs-error-c2664-return-string-from-a-function-c string Student::getName() { return studentName; } On compile, I get this error from VS10: Error 1 error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(const std::basic_string<_Elem,_Traits,_Ax> &)' : cannot convert parameter 1 from 'std::string [30]' to 'const std::basic_string<_Elem,_Traits,_Ax> &' f:\c++\hw1\hw1\hw3\hw3.cpp 56 1 HW3 I'm not sure what this means. If anyone can clarify I would be thankful. Also, in these get functions is it common to return a reference for the string or actual literal values (hope this is the correct lingo). StudentName declared as such: protected: string studentName[30]; int studentGrades[8]; int studentAge; }; c++ string return share|improve this question edited May 24 '14 at 12:38 asked May 24 '14 at 12:33 user34920 125229 How studentName is defined in your class? –Adrian Toma May 24 '14 at 12:36 string studentName[30]; is an array of thirty strings - is that really what you wanted? –RichieHindle May 24 '14 at 12:36 studentName is defined to be not a string, but an array of 30 strings. You cannot pass an array of strings as a string. –Andrey Chernyakhovskiy May 24 '14 at 12:37 2 you simply need to declare it as string studentName; it's enougth –Adrian Toma May 24 '14 at 12:39 @at0ma - what do you mean? –user34920 May 24 '14
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and http://stackoverflow.com/questions/8643479/error-c2664-sprintf-cannot-convert-parameter-1-from-stdstring-to-char policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes error c2664 a minute: Sign up Error C2664: 'sprintf' : cannot convert parameter 1 from 'std::string' to 'char *' up vote 0 down vote favorite Below is the insert function in VC++. I am getting this error when I change the char to string data type to read the value of amount variable in the below code. static void Insert(t_analysis* analysis) { _bstr_t strunitId; error c2664 cannot _bstr_t strGdt=time(0); _bstr_t strvalue; std::string str; std::string commandStr = "insert into table1(unitid,g_time_dte_1,h_1,n_1,ch_1,co_1,im_1,ve_1,er_1) Values(123,'" + strGdt +"',"; char tempBuf[50]; for (int j = 0; j < analysis->ubPeaksIntTab;j++ ) { sprintf(tempBuf, "%d", (analysis->peak + j)->amount);//here it takes the adrress of amount but not the value of amount variable. str += commandStr + tempBuf; if(j!=analysis->ubPeaksIntTab-1) commandStr += ","; } commandStr += ")"; _ConnectionPtr pConn = NULL; try { HRESULT hr = S_OK; CoInitialize(NULL); hr = pConn.CreateInstance((__uuidof(Connection))); _bstr_t strCon("Provider=SQLOLEDB;Dataq Source=MYPC\\SQLEXPRESS;Initial Catalog=keerth;User ID=sa;Password=password;Connect Timeout=30;"); if(FAILED(hr)) { printf("Error instantiating Connection object\n"); } hr = pConn->Open(strCon,"sa","password",0); if(FAILED(hr)) { printf("Error Opening Database object using ADO _ConnectionPtr \n"); } //Execute the insert statement pConn->Execute(commandStr.c_str(), NULL,adExecuteNoRecords); pConn->Close(); } catch(_com_error &ce) { printf("Error:%s\n",ce.ErrorMessage()); pConn->Close(); } } Whenever I run this getting the Error. Then I changed the char tempbuf[50]; to std::string str1;. Now it is showing: Error C2664: 'sprintf' : cannot convert parameter 1 from 'std::string' to 'char *; The amount variable contains the float value. How can I copy the float value assign it to string variable? visual-c++ share|improve this question edited Dec 27 '11 at 11:22 pmg 69.1k782139 asked Dec 2