为什么显示 - "无法传递非平凡可复制类型的对象"?

 工商领域LW 发布于 2022-12-25 20:50

您不必从头开始完成完整的代码.问题出在main里面的execl(..)语句中.代码是 -

#include 
#include 
#include 
#include 
#include 
#include 

#define li long int

using namespace std;


char TypedCommandInTerminal[1001];
vector  ValidCommands,TypedCommand;


void ShowTerminal()
{
    cout<<"User:$ ";
    gets(TypedCommandInTerminal);
}


void PushCommands()
{
    ValidCommands.push_back("mkdir");
}


void GetCommandIntoVector()
{
    TypedCommand.clear();

    char *p = strtok(TypedCommandInTerminal," ");

    while(p)
    {
        TypedCommand.push_back(p);
        p = strtok(NULL," ");
    }
}

bool MatchCommand(string Command)
{
    li i;

    for(i=0;i

我试图在linux中使用c ++设计一个简单的终端.我在这里要做的是 - 在控制台中将此命令作为输入 - "mkdir ab".然后我设法对这个字符串进行了标记,并在TypedCommand [1]中的TypedCommand [0]和"ab"中保留了"mkdir".问题是当我在execl编译器中写入"TypedCommand [1]"时出现错误 - "无法传递非平凡可复制类型的对象....."我删除了TypedCommand [1]并手动编写了"ab"到位它的.代码运行并在执行目录中创建名为"ab"的文件夹.所以看起来像execl工作正常.

我需要以某种方式在execl中传递保存在TypedCommand [1]中的第二个字符串......这里有什么问题?

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有