السلام عليكم ورحمة الله وبركاته
عندي هذا الكود ولكن به خطأ
#include <iostream>
#include <string>
using namespace std;
void someFunction()
{
const int DATASIZE = 50000;
int data[DATASIZE];
for (int i =0; i < DATASIZE; i++)
{
data = 99;
}
};
int* createAndFillArray()
{
int somedata[2000];
int myarray[10];
for (int i = 0; i < 10; i++)
{
myarray = i * 10;
}
return &myarray[0];
}
int main(int argc, char* argv[])
{
int *nums;
nums = createAndFillArray();
someFunction();
cout << "Array Elements" << endl;
for (int i = 0; i < 10; i++)
{
cout << nums << " ";
}
cin.get();
}
المخرجات هي كالتالي
99 99 99 99 99 99 99 99 99
من المفروض ان تكون
0 10 20 30 40 50 60 70 80 90
مع العلم انه لا يمكننا مسح اي داله