[英]Issues with FLTK and concatenated char
I working on FLTK application (C++) and I have to create names to set in a Fl_Browser. 我正在使用FLTK应用程序(C ++),并且必须创建要在Fl_Browser中设置的名称。 Basically this structure receive a "const char*" with 基本上,此结构会收到一个“ const char *”
browser->add("my string.."); browser-> add(“ my string ..”);
but... I need that each string receive the correct name: "Process" plus the it number, like: "Process 1", "Process 2", ... 但是...我需要每个字符串都接收正确的名称:“进程”加上它的数字,例如:“进程1”,“进程2”,...
the entire string must be a const char*, the number is receive by a counter, which is increased by a while command; 整个字符串必须是const char *,该数字由计数器接收,并由while命令增加;
I need something like this: 我需要这样的东西:
int count=1;
while (count < 100) {
const char* name;
name = "Process" + count;
count++;
}
How can I concat this two variables? 如何连接这两个变量?
You should use a string stream, like this: 您应该使用字符串流,如下所示:
while (count < 100) {
std::ostringstream name;
name << "Process" << count;
browser->add(name.str().c_str());
count++;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.