FLTK和串联char的问题

Issues with FLTK and concatenated char

本文关键字:问题 char FLTK      更新时间:2023-10-16

i在FLTK应用程序(C )上工作,我必须创建在FL_Browser中设置的名称。基本上,此结构以

获得" const char*"

浏览器 -> add("我的字符串..");

但是...我需要每个字符串接收正确的名称:" process"加上IT号,例如:" process 1"," Process 2",...

整个字符串必须是const char*,数字是由计数器接收的,该数字增加了一定的命令;

我需要这样的东西:

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++;
}