FLTK 和连接字符的问题
Issues with FLTK and concatenated char
我正在开发 FLTK 应用程序 (C++),我必须创建要在 Fl_Browser 中设置的名称。基本上这个结构接收 "const char*" 和
浏览器->添加("my string..");
但是...我需要每个字符串都收到正确的名称:"Process" 加上它的编号,例如:"Process 1"、"Process 2"、...
整个字符串必须是一个const char*,数字由计数器接收,通过while命令递增;
我需要这样的东西:
int count=1;
while (count < 100) {
const char* name;
name = "Process" + count;
count++;
}
如何连接这两个变量?
您应该使用字符串流,如下所示:
while (count < 100) {
std::ostringstream name;
name << "Process" << count;
browser->add(name.str().c_str());
count++;
}
我正在开发 FLTK 应用程序 (C++),我必须创建要在 Fl_Browser 中设置的名称。基本上这个结构接收 "const char*" 和
浏览器->添加("my string..");
但是...我需要每个字符串都收到正确的名称:"Process" 加上它的编号,例如:"Process 1"、"Process 2"、...
整个字符串必须是一个const char*,数字由计数器接收,通过while命令递增;
我需要这样的东西:
int count=1;
while (count < 100) {
const char* name;
name = "Process" + count;
count++;
}
如何连接这两个变量?
您应该使用字符串流,如下所示:
while (count < 100) {
std::ostringstream name;
name << "Process" << count;
browser->add(name.str().c_str());
count++;
}