2013-09-29 68 views
-1

我得到followint錯誤:C++錯誤C3867

error C3867: 'std::basic_string<_Elem,_Traits,_Ax>::c_str': function call missing argument list; use '&std::basic_string<_Elem,_Traits,_Ax>::c_str' to create a pointer to member

#include "stdafx.h" 
#include <iostream> 
#include <Windows.h> 
#using <System.dll> 
#include <sstream> 
#include <string> 
using namespace System::Net; 
using namespace std; 

int main(array<System::String ^> ^args) 
{ 
int input; 
cout << "Welcome to the prize draw!!" << endl; 
cout << "Please enter your age - "; 
cin >> input; 
cin.ignore(); 
if (input < 13){ 
    cout << "You must be 13 or over to enter" << endl; 
} 
else 
{ 
    cout << "You will now be entered..." << endl; 
    WebClient^ client = gcnew WebClient; 
    client->Credentials = gcnew NetworkCredential ("user","pass"); 
    System::String^ num = client->DownloadString("ftp://ftpaddress/code.txt"); 
    ostringstream converter; 
    int number = int::Parse(num); 
    int numup = number +1; 
    converter << (numup); 
    // I get the error here - 
     System::String^ newnum = gcnew System::String(converter.str().c_str); 
    client->UploadString("ftp://ftpaddress/code.txt", newnum); 
    System::String^ win = client->DownloadString("ftp://ftpaddress/wincode.txt"); 
    if (num == win){ 
    cout << "You have won a prize!!! - " << endl; 
    int newwin = int::Parse(win) + rand() % (int::Parse(win) * 5); 
    ostringstream convert; 
    convert << newwin; 
    // I get the error here, too - 
     System::String^ toupload = gcnew System::String(convert.str().c_str); 
    client ->UploadString("ftp://ftpaddress/wincode.txt",toupload); 
    } 
    else 
    { 
     cout << "Sorry, you didn't win this time" << endl; 
    } 
} 
return 0; 

}

我該怎麼辦?

回答

4

c_strstd::string成員函數,所以你需要用()調用它:

gcnew System::String(converter.str().c_str()); 
//          ^^ HERE! 
+0

非常感謝,它的工作。我趕着代碼,忘了! – Joe