How to convert from C++ std::string type to S type

Subject: How to convert from C++ std::string type to S typeMessage-Id: <5CA71687-362E-47A0-A4FE-4793107EE97D@gmail.com>Date: Tue, 13 Aug 2013 20:47:00 +0800To: personal-kdbplus@googlegroups.comMime-Version: 1.0 (Mac OS X Mail 6.5 (1508))X-Mailer: Apple Mail (2.1508)Hi, AllI need to insert data into kdb database with C++ code.I want to set parameter sql with a std::string type and pass to function: k(handle,sql,(K)0).However, function k only accept S type.How to convert from C++ std::string type to S type??Thanks!---------------void InsertDB(int handle, string sql){ K result; result = k(handle,sql,(K)0); if (!result) { printf(“Network Error\n”); perror(“Network”); exit(1); } else if (result->t == -128) { printf(“Server Error %s\n”,result->s); kclose(handle); exit(1); } else { printf(“insert OK”); } kclose(handle); r0(result);}

k(handle,sql.c_str(),(K)0);

Hi Felix,

I have a try and still error:

error C2664: ‘k’ : cannot convert parameter 2 from ‘const char *’ to ‘const S’


Best Regards,
Roy Liu

Cast it.

(S)sql.c_str()…

În data de 13.08.2013 15:59, <liuchuanbo@gmail.com> a scris:

Hi Felix,

I have a try and still error:

error C2664: ‘k’ : cannot convert parameter 2 from ‘const char *’ to ‘const S’


Best Regards,
Roy Liu

It works!
thank you Felix.