gpt4 book ai didi

c++ - Setenv:在初始值设定项中将类型表达式列表视为复合表达式

转载 作者:行者123 更新时间:2023-11-28 06:20:04 40 4
gpt4 key购买 nike

获取 在初始化程序中将类型表达式列表视为复合表达式在这两个函数调用上 -

    char itoa(new_total, new_total_ch, 10);
int setenv("COUNT_TOTAL", new_total_ch, 1);

这是代码片段-

#include <iostream>
// create process team
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <ctime>
// initialize & process
#include <time.h>
#include <string>
#include <fstream>
#include <cmath>
#include <iosfwd>
// initialize & process
using std::ifstream;
using namespace std;

class Count3sProcessParallel {

public:
//int process();
int pr_count;
int process();
typedef int COUNT_TOTAL;


private:

int worker;
//declare process()
long unit_of_work;
long lower_bound;
long upper_bound;
int pr_i;
char * ct;
int ct_i;
int new_total;
char itoa();
char * new_total_ch;
int setenv();

};


int Count3sProcessParallel::process() {
// determine upper lower bounds
unit_of_work = in_length/workers_num;
lower_bound = (worker -1) * unit_of_work;
upper_bound = (worker * unit_of_work) -1;

// iterate and count
pr_count = 0;
for (pr_i = lower_bound; pr_i < upper_bound; pr_i++)
if (floor(in_buffer[pr_i] == 3))
pr_count++;
return pr_count;

//update COUNT_TOTAL
ct = getenv("COUNT_TOTAL");
ct_i = atoi(ct);
new_total = (pr_count + ct_i);
char * new_total_ch[33];
char itoa(new_total, new_total_ch, 10);
int setenv("COUNT_TOTAL", new_total_ch, 1);

delete[] in_buffer;
return 0;
}

我该如何解决这个问题?谢谢。

最佳答案

删除前导类型。只需使用:

itoa(new_total, new_total_ch, 10);
setenv("COUNT_TOTAL", new_total_ch, 1);

关于c++ - Setenv:在初始值设定项中将类型表达式列表视为复合表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29466070/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com