Ich weiß, auch wenn ich ein Array übergeben durch Eingabe von Arrayname als Argument (zB: getArrayInput (arrayexample);), wird nur den Adresswert des ersten Elements nicht ganz kopiert Array, immer noch ich frage mich, warum diese Code Fehler gibt. Ich weiß das nicht so wie es umgesetzt werden soll aber ich will diesen Fehler verstehen.Übergabe eines Zeigers an ein int-Array, als Argument C++
main.cpp|13|error: cannot convert 'int*' to 'int**' for argument '1' to 'void getArrayInput(int**)'|
#include <iostream>
using namespace std;
void getArrayInput(int * []);
int main()
{
cout<<"Enter scores on by one.." << endl;
cout<<"To terminate input enter -1"<<endl;
int listof[10]={};
int *ptScores =listof;
getArrayInput(ptScores);
return 0;
}
void getArrayInput(int * []){
for(int i=0;i<10;i++){
cin>>*(pt+i);
if(*(pt+i))=-1){
break;
}
else{
cout<<"Enter next.."<<endl;
}
}
}
Willkommen in C++, wo Sie 'Std 0:' ohne Aufpreis erhalten. –
Bathsheba
Übrigens, Sie sind gefährlich nahe an Überlauf/außerhalb der Grenzen schreiben. –