简体   繁体   English

在MoSync中将数据写入文件(将MAUtil :: String转换为const char *)

[英]Writing data to file in MoSync (Converting MAUtil::String to const char*)

I'm trying to write some data to a file in Mosync. 我正在尝试将一些数据写入Mosync中的文件。 This is what I'm doing: 这就是我在做什么:

String filename = "c:\\hamburger.txt";
MAHandle newfile = maFileOpen (&filename, MA_ACCESS_READ_WRITE);
maFileCreate (newfile);
maFileWrite (newfile, &keyCode, 1);

The error occurs at line 2, 错误发生在第2行

MAHandle newfile = maFileOpen (&filename, MA_ACCESS_READ_WRITE); 

when trying to open the address at &filename. 尝试在&filename中打开地址时。 It says it can't convert a MAUtil::String to a const char* . 它说它不能将MAUtil::String转换为const char*

You can convert a MAUtil::String into a const char* with .c_str() . 您可以使用.c_str()MAUtil::String转换为const char*

Thus, instead of &filename , I used filename.c_str() and it compiled. 因此,我使用filename.c_str()而不是&filename编译。 The entire code still does not work, however. 但是,整个代码仍然无法正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM