小编Dav*_*vid的帖子

C:将结构传递给函数不会导致按值运算调用

我在Visual C++中编写的程序存在以下问题,希望有人能帮助我:

typedef struct spielfeld
{
 int ** Matrix;
 int height; 
 int width; 
 Walker walker;
 Verlauf history;
} Spielfeld;

void show(Spielfeld fieldToShow); //Prototype of the Function where I have this
                                  //problem

int main(int argc, char *argv[])
{
  int eingabe;
  Spielfeld field;

  //Initialize .. and so on

  //Call show-Function and pass the structure with Call by Value
  show(field);
  //But what's happened? field.Matrix has changed!!
  //can anyone tell me why? I don't want it to become changed!
  //cause that's the reason why …
Run Code Online (Sandbox Code Playgroud)

c struct function parameter-passing

2
推荐指数
1
解决办法
5607
查看次数

标签 统计

c ×1

function ×1

parameter-passing ×1

struct ×1