Here is a code it print only single value If I want to print whole array it does not work well.
#include <iostream>
using namespace std;
int *firstDay(int fd)
{
int d[35] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int setday = 1;
int *pnd;
pnd = d;
int limit = 35 - fd;
for(fd;fd<limit;fd++)
{
d[fd] = setday;
setday++;
}
return pnd;
}
void display(int *d)
{
cout<<d[1]<<endl; // value 0
cout<<d[2]<<endl; // value 1
cout<<d[3]; // value 2
}
int main()
{
display(firstDay(2));
return 0;
}
If I write only one cout
then it works and print correct value If I use more then one cout
then it can not print correct value.