Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ &引用;无法将字符*转换为字符(*)[95]”;错误_C++_Arrays_Compiler Errors - Fatal编程技术网

C++ &引用;无法将字符*转换为字符(*)[95]”;错误

C++ &引用;无法将字符*转换为字符(*)[95]”;错误,c++,arrays,compiler-errors,C++,Arrays,Compiler Errors,我有使用数组创建ASCII表的代码。由于以下错误,我在编译代码时遇到问题: 无法将参数“1”的“char*”转换为char(*)[95]以使buildTable无效(char(8)[95],int) 及 无法将参数“1”的std::ofstream转换为char(*)[95]到“void printTable(char(8)[95],int)” #包括 #包括 #包括 int main(){ const int MAX_SIZE=95; 字符符号[最大大小]; int值[MAX_SiZE],in

我有使用数组创建ASCII表的代码。由于以下错误,我在编译代码时遇到问题:

无法将参数“1”的“char*”转换为char(*)[95]以使buildTable无效(char(8)[95],int)

无法将参数“1”的std::ofstream转换为char(*)[95]到“void printTable(char(8)[95],int)”

#包括
#包括
#包括
int main(){
const int MAX_SIZE=95;
字符符号[最大大小];
int值[MAX_SiZE],int值);
void buildTable(char[][MAX_SIZE],int值);
无效打印表(字符[][MAX_SIZE],int值);
无效输出(std::fstream,std::string,double);
std::字符串行;
std::of流输出文件;
outputFile.open(“ascii.log”);
if(outputFile.fail()){

std::cout变量
symbols
是一个
char
数组。它将衰减为指向其第一个元素
&symbols[0]
的指针,其类型为
char*

您声明的函数将其第一个参数作为指向
char
数组的指针。指向
char
数组的指针与指向
char
的指针非常不同

解决方案是使函数采用与您传递的数据类型相同的数据类型,即指向
char
char*
的指针

您还存在多个其他问题。例如,您声明的函数(
buildTable
printTable
)当前声明为将此错误参数作为第一个参数,然后将
int
value作为第二个参数。但这不是调用这些函数的方式。您需要使用实际参数声明函数,并按声明的方式调用它们



<>相关注释:由于C++中的编程,请不要使用字符串数组,使用“代码> STD::String < /Cord>”。从长远来看,这将节省大量的时间。

谢谢。我对编码非常新。
你应该有
char*
@KAJ看看你所拥有的函数的声明。然后看看你如何调用它们。它匹配吗?@KAJ是的,你声明函数有两个参数,然后你用三个参数调用它。这是无效的。而且第二个参数也不匹配。@KAJ不,我告诉你你需要想一想。函数实际上是如何定义的?它们真正采用什么参数?你需要传递什么参数?Stack Overflow不是一个教程或手持站点。如果我听起来粗鲁,我很抱歉,但你需要能够自己想一想。对于下一个问题,请abnd学习如何创建。
#include <iomanip>
#include <iostream> 
#include <fstream> 

int main () {
    const int MAX_SIZE = 95;
    char symbols[MAX_SIZE];
    int values[MAX_SiZE], int values);
    void buildTable (char [][MAX_SIZE], int values);
    void printTable (char [][MAX_SIZE], int values);
    void output(std::fstream, std::string, double); 

    std::string line;

    std::ofstream outputFile;
    outputFile.open("ascii.log");
    if(outputFile.fail()) {
        std::cout << "Error opening file. \n";
        return 1;
    }
    else {
        buildTable (symbols, values, MAX_SIZE);
        printTable (outputFile, symbols, values, MAX_SIZE);
    }
    outputFile.close();
    return 0;
}