English 中文(简体)
穿过2个阵列以在C发挥作用?
原标题:Pass 2d array to function in C?

我知道这很简单,但我似乎没有做这项工作。

我的职能如下:

 int GefMain(int array[][5])
 {
      //do stuff
      return 1;
 }

主要内容是:

 int GefMain(int array[][5]);

 int main(void)
 {
      int array[1800][5];

      GefMain(array);

      return 0;
 }

我提到了,但我仍在收到错误的 警告:将GefMain从不相容的电梯类型中的第1号论点转过错?

EDIT:

该法典有两份档案,由汇编者共同使用。 我没有使用电梯。 以上法典完全是我拥有的,但主要职能被宣布为“永久不可侵犯”。 谢谢大家。

最佳回答

该法典是罚款。 在一份单一档案中,这部文件对我课以鞭.。

int g(int arr[][5])
{
    return 1;
}

int main()
{
    int array[1800][5];
    g(array);
    return 0;
}

我的猜测是,你重读了#include,把错误的档案——或许还有一份对GefMain的声明。 或者,或许你只是避开了已申报的<代码>GefMain的档案,因此它仍然有<编码>int [3]的论点,例如,这将引起警告。

我建议你把整个法典放在首位,以复制问题(当然,在你排除了无需复制的问题之后)。 但此时此刻,你已经解决了这一问题。

问题回答

甚至在<代码>-std=c99-pedantic的备选办法中汇编了正确的内容。 ...... 你们想要我们检查这部法律吗? • 要求你重新使用......?

<>代码>gcc将可延伸到您(和其他人已提出过申请)。 相反,它更适合其他汇编者:

int g(int (* arr)[5])
{
    return 1;
}

int main()
{
    int array[1800][5];
    g(array);
    return 0;
}

或更好;

int g(int (* arr)[5], int count)
{
    return 1;
}

int main()
{
    int array[1800][5];
    g(array, sizeof(array)/sizeof(* array));
    return 0;
}

你再次发出警告,因为一系列问题在作为争辩通过时变成了点,上述情况使汇编者看到了它应当期望的一点。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签