SashaBuilder3
Programmer
Hi everybody!
Here is a simple sample program, it works OK, but I am not sure if such pointer assignment could be used freely (both in DOS and Windows). Can anyone clarify this issue?
#include <stdio.h>
#include <conio.h>
//Global pointer
int *PtrGlob;
void ArraySetting(int n)
{
//local pointer
int *ptrLoc;
//memory allocation using the local pointer
ptrLoc=new int[n];
//the pointer assignment
PtrGlob=ptrLoc;
}
void main()
{
int i,n=1000;
ArraySetting;
//sample usage of the global array
for(i=0;i<n;i++)
PtrGlob=i+10;
for(i=0;i<n;i++)
printf("i=%4d Value=%4d\n",i+1,PtrGlob);
getch();
}
And who can expalain why in posted text in some lines the square brackets disappear?
Here is a simple sample program, it works OK, but I am not sure if such pointer assignment could be used freely (both in DOS and Windows). Can anyone clarify this issue?
#include <stdio.h>
#include <conio.h>
//Global pointer
int *PtrGlob;
void ArraySetting(int n)
{
//local pointer
int *ptrLoc;
//memory allocation using the local pointer
ptrLoc=new int[n];
//the pointer assignment
PtrGlob=ptrLoc;
}
void main()
{
int i,n=1000;
ArraySetting;
//sample usage of the global array
for(i=0;i<n;i++)
PtrGlob=i+10;
for(i=0;i<n;i++)
printf("i=%4d Value=%4d\n",i+1,PtrGlob);
getch();
}
And who can expalain why in posted text in some lines the square brackets disappear?