I am using borland compiler...

i need to define 4 gloabal arrays of double type that can store 5000 values

like

double d[5000],d2[5000],d3[5000],d4[5000]..

and an array of objects of class data whose syntax is:

class data
{
public:
int x,y;
double s,w,e,d;
}d[5000],f[5000];

i am facing two errors:

array size too large
and too much global data defined in file..

can anyone help me please.I will be extremely thankful to you....

do i have to switch over to other compiler??If yes. please tell me the one which can solve my problem for sure and i dont have to make ammendments in my coding as I dont have much time...

If you have old Borland's 16-bit compiler, I'm not sure that you can solve your problem with array size constraints.
May be try:
1. Select huge memory model.
2. Declare global double* pointers d, d2, d3, d3 and allocate arrays dynamically

d = new double[5000];
... and so on in that manner

You will get absolutely identical array access code (don't use sizeof(d), of course)...

Better download freeware 32-bit compiler+IDE right now ;)!

VC++ 2008 distribution is too large (~400 MB) but Code::Blocks with MinGW compiler is much more lighter...

what about g++ compiler??

well i have 2 more days and one of my friend is familiar with g++ compiler....he told me that i dont even have to do editing in .cpp file in g++ compiler..what will you suggest??? I am using TCW 4.5...

I am trying visual c++ 2005 for last 2 days and i m really frustated of this software...i still have 88 errors..though all are the same...

please suggest me best and easiest way to tackle this problem.........

Most likely you have lots of errors because of Borland/DOS specific stuff in your sources. So you will have same errors with g++ and all other compilers.

VC++ 2005 is a very good compiler+IDE. If you have its installation, use it!

Post your code fragments. As usually, it's not so hard task to move a simple console program in a new environment (of course, it depends ;).

You need to post code and the first fiew error messages (certainly NOT all 88 errors!). I just compiled this with VC++ 2008 Express without error

struct data
{
int x,y;
double s,w,e,d;
}d[5000],f[5000];


int main()
{ 

}

This is my complete code....i am getting 88 errors..can you help me in editing iit???

#include<fstream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<process.h>
#include<math.h>
#include<iomanip.h>

/* some global variables to store maximum scanning area in x,y direction and grid distances */
int x,y,k,l,a,b;
/* p,q will store value to be used in calculation using formula */
float p,q;
/* global arrays to store sum of various sigmas which are used in formulae */
float distance[5000],distance1[5000],distance2[5000], tw[5000];

/* a class named as data where voltages will be stored */
class data
		{
		public:
		int x_component,y_component;
		float real_z1,imaginary_z1;
		float real_z2,imaginary_z2;
		void getdata();
		}d[5000],f[5000];

int c=0;

/* function to get data from data.txt */
void gtdata()
	{
	 FILE *fp;
	 c = 0;
	 fp=fopen("data1.txt","r");
	 if(fp==NULL)
	  {
		puts("Cannot open file");
	  }
	 while(fscanf(fp,"%d %d %e %e %e %e", &d[c].x_component, &d[c].y_component, &d[c].real_z1, &d[c].imaginary_z1, &d[c].real_z2, &d[c].imaginary_z2)!= EOF)
	 {
	  printf("%d",d[c].x_component);
	  printf("%d",d[c].y_component);
	  printf("%e",d[c].real_z1);
	  printf("%e",d[c].imaginary_z1);
	  printf("%e",d[c].real_z2);
	  printf("%e",d[c].imaginary_z1);
	  c++;
	  }
	  fclose(fp);
	 }




/* function to calculate volatges at different parts of the grid or you can say to calculate u1,u2,u3,u4 */
void calculation(data a[], int i, int j,int g)
	{
	int w,l,f,g1;
	float h,u,cw;
	float sum=0,sum1=0,sum2=0,sumd=0;
	/* this for loop will calculate how many total no. of objects will affect a particular grid position i ,j */
	/* loop to calculate the distance between m1 and xi */
	for(int s=0;s<g;s++)
		{
		sum=0;
		sum1=0;
		w=pow((a[s].x_component-i),2);
		l=pow((a[s].y_component-j),2);
		h=sqrt(w+l);
		/* all such ditances like m1 to i,j and m2 to i,j will be stored into an array distance1 */
		distance1[s]=h;
		/* this loop will calculate distance between m1 to m2,m3 and so on..*/
		for(int m=0;m<g;m++)
			{
			if(m!=s)
				{
				f=pow((a[s].x_component-a[m].x_component),2);
				g1=pow((a[s].y_component-a[m].y_component),2);
				u=sqrt(f+g1);
				if(u<=h)
					{
					/* this sum and sum1 are used in calculating cw1 */
					sum+=(1-(u/h));
					sum1+=((1-(u/h))* (pow(u,p)));
					}
				}
			}
		cw=((h+sum1)/(h*(1+ sum)));
		// cw1,cw2...all will be stored in an array distance
		distance[s]=cw;
		}
	// loop to calculate sum of dij to the power -q;
	for(s=0;s<g;s++)
		{
		sum2+=pow(distance1[s],-q);
		}
	// dw1,dw2 will be calculated and stored in an array of distance2
	for(s=0;s<g;s++)
		{
		distance2[s]=((pow(distance1[s],-q))/sum2);
		}
	/* total weight is calculated for all objects and stored in an array of tw */
	for(int lo=0;lo<g;lo++)
	  {
	  tw[lo]=distance2[lo]*distance[lo];
	  }
	/* sum of total weights is calculated and saved in sumd, this is used in calculating u1,u2,u3,u4 */
	for(int as=0;as<g;as++)
		{
		sumd+=tw[as];
		}
	/* the final result for a particular grid i j */
	float u1,u2,u3,u4;
	u1=u2=u3=u4=0;
	cout<<endl;
	cout<<"\n""Data at position ["<<i<<" ,"<<j<<" ]";
	for(int result=0;result<g;result++)
		{
		u1+=((a[result].real_z1*tw[result])/sumd);
		u2+=((a[result].imaginary_z1*tw[result])/sumd);
		u3+=((a[result].real_z2*tw[result])/sumd);
		u4+=((a[result].imaginary_z2*tw[result])/sumd);
		}

		cout<<"\n""Value of U1: "<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u1;
		cout<<"\n""Value of U2: "<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u2;
		cout<<"\n""Value of U3: "<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u3;
		cout<<"\n""Value of U4: "<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u4;

 }
/* function to search which object will affect the grid volatage */
void selection()
	{
	int g=0;
	/* i and j are grid positions which will run from 0,0 till the max. scanning area */
	/* k is used to scan all the stored data to know which object will be used to calculate grid volatages */
	for(int j=0;j<y;j=j+l)
		{
		for(int i=0;i<x;i=i+k)
			{
			g=0;
			 for( int k=0;k<c;k++)
				{
				/* a and b are the deltax and deltay. If an object comes under this area, it will affect grid volatages.Total objects are stored in f array */
				if(abs(d[k].x_component-i) <=a )
					{
					if(abs(d[k].y_component-j) <=b )
						{
						f[g]=d[k];
						g++;
						}
					}
				}
			 calculation(f,i,j,g);
			 }
		}
	}
void main()
		{
		clrscr();
		/* initialising all objects of class data to zero */
		cout<<"Entered  data is ""\n";
		gtdata();
		cout<<"\n""Enter the maximum value of scanning in x direction";
		cin>>x;
		cout<<"\n""Enter the maximum value of scanning in y direction";
		cin>>y;
		cout<<"\n""Enter the value of distance between the grids in x axis";
		cin>>k;
		cout<<"\n""Enter the value of distance between the grids in y axis";
		cin>>l;
		cout<<"\n""Enter the value of deltax";
		cin>>a;
		cout<<"\n""Enter the value of deltay";
		cin>>b;
		cout<<"\n""Enter the value of p";
		cin>>p;
		cout<<"\n""Enter the value of q";
		cin>>q;
		selection();
		getch();
		}
Comments
By 10+ posts, you should have figured out code tags, but Nooooo. Here's a cookie.

When you post code, use code tags, i.e.
[code=cpp]
< paste your code here in between the tags >

[/code]

Below is a close-to-compilable version for e.g. VC 2005, the errors that are left, are about the usage of pow() and sqrt() functions. Your choice of argument types for these functions do not match the function signatures, meaning that you may want to change the respective data types or type cast the arguments as needed. I think ArkM pretty much pointed out that already earlierly.
Also I added using namespace std; , if you are not lazy, you can replace it with what ArkM suggested earlierly (i.e. using std::cout etc).

#include "stdafx.h"

#include <fstream> // <fstream.h>
#include <iostream> 
#include <conio.h>
// #include <string.h> // not used anywhere
// #include <stdio.h> // not used anywhere
// #include <process.h> // not used anywhere
#include <cmath> // <math.h>
#include <iomanip> // <iomanip.h>

using namespace std;

/* some global variables to store maximum scanning area in x,y direction and grid distances */
int x,y,k,l,a,b;
/* p,q will store value to be used in calculation using formula */
float p,q;

/* global arrays to store sum of various sigmas which are used in formulae */

// float distance[5000] => float distance0[5000]  to avoid colliding with std namespace.

float distance0[5000],distance1[5000],distance2[5000], tw[5000];

/* a class named as data where voltages will be stored */
class data
{
public:
	int x_component,y_component;
	float real_z1,imaginary_z1;
	float real_z2,imaginary_z2;
	void getdata();
}d[5000],f[5000];

int c=0;

/* function to get data from data.txt */
void gtdata()
{
	FILE *fp;
	c = 0;
	fp=fopen("data1.txt","r");
	if(fp==NULL)
	{
		puts("Cannot open file");
	}
	while(fscanf(fp,"%d %d %e %e %e %e", &d[c].x_component, &d[c].y_component, &d[c].real_z1, &d[c].imaginary_z1, &d[c].real_z2, &d[c].imaginary_z2)!= EOF)
	{
		printf("%d",d[c].x_component);
		printf("%d",d[c].y_component);
		printf("%e",d[c].real_z1);
		printf("%e",d[c].imaginary_z1);
		printf("%e",d[c].real_z2);
		printf("%e",d[c].imaginary_z1);
		c++;
	}
	fclose(fp);
}

/* function to calculate volatges at different parts of the grid or you can say to calculate u1,u2,u3,u4 */
void calculation(data a[], int i, int j,int g)
{
	int w,l,f,g1;
	float h,u,cw;
	float sum=0,sum1=0,sum2=0,sumd=0;
	/* this for loop will calculate how many total no. of objects will affect a particular grid position i ,j */
	/* loop to calculate the distance between m1 and xi */

	// for(int s=0;s<g;s++)
	int s;  // 's' will be reused later in other for loops ... 
	for(s=0;s<g;s++)
	{
		sum=0;
		sum1=0;
		w=pow((a[s].x_component-i),2);
		l=pow((a[s].y_component-j),2);
		h=sqrt(w+l);
		/* all such ditances like m1 to i,j and m2 to i,j will be stored into an array distance1 */
		distance1[s]=h;
		/* this loop will calculate distance between m1 to m2,m3 and so on..*/
		for(int m=0;m<g;m++)
		{
			if(m!=s)
			{
				f=pow((a[s].x_component-a[m].x_component),2);
				g1=pow((a[s].y_component-a[m].y_component),2);
				u=sqrt(f+g1);
				if(u<=h)
				{
					/* this sum and sum1 are used in calculating cw1 */
					sum+=(1-(u/h));
					sum1+=((1-(u/h))* (pow(u,p)));
				}
			}
		}
		cw=((h+sum1)/(h*(1+ sum)));
		// cw1,cw2...all will be stored in an array distance
		distance0[s]=cw;
	}
	// loop to calculate sum of dij to the power -q;
	for(s=0;s<g;s++)
	{
		sum2+=pow(distance1[s],-q);
	}
	// dw1,dw2 will be calculated and stored in an array of distance2
	for(s=0;s<g;s++)
	{
		distance2[s]=((pow(distance1[s],-q))/sum2);
	}
	/* total weight is calculated for all objects and stored in an array of tw */
	for(int lo=0;lo<g;lo++)
	{
		tw[lo]=distance2[lo]*distance0[lo];
	}
	/* sum of total weights is calculated and saved in sumd, this is used in calculating u1,u2,u3,u4 */
	for(int as=0;as<g;as++)
	{
		sumd+=tw[as];
	}
	/* the final result for a particular grid i j */
	float u1,u2,u3,u4;
	u1=u2=u3=u4=0;
	cout<<endl;
	cout<<"\n""Data at position ["<<i<<" ,"<<j<<" ]";
	for(int result=0;result<g;result++)
	{
		u1+=((a[result].real_z1*tw[result])/sumd);
		u2+=((a[result].imaginary_z1*tw[result])/sumd);
		u3+=((a[result].real_z2*tw[result])/sumd);
		u4+=((a[result].imaginary_z2*tw[result])/sumd);
	}

	cout<<"\n""Value of U1: "<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u1;
	cout<<"\n""Value of U2: "<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u2;
	cout<<"\n""Value of U3: "<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u3;
	cout<<"\n""Value of U4: "<<setiosflags(ios::scientific)<<setw(10)<<setprecision(8)<<u4;

}
/* function to search which object will affect the grid volatage */
void selection()
{
	int g=0;
	/* i and j are grid positions which will run from 0,0 till the max. scanning area */
	/* k is used to scan all the stored data to know which object will be used to calculate grid volatages */
	for(int j=0;j<y;j=j+l)
	{
		for(int i=0;i<x;i=i+k)
		{
			g=0;
			for( int k=0;k<c;k++)
			{
				/* a and b are the deltax and deltay. If an object comes under this area, it will affect grid volatages.Total objects are stored in f array */
				if(abs(d[k].x_component-i) <=a )
				{
					if(abs(d[k].y_component-j) <=b )
					{
						f[g]=d[k];
						g++;
					}
				}
			}
			calculation(f,i,j,g);
		}
	}
}

int main()
// void main() - do NOT use 'void main()'
{
//	clrscr(); // do not use clrscr()
	/* initialising all objects of class data to zero */
	cout<<"Entered data is ""\n";
	gtdata();
	cout<<"\n""Enter the maximum value of scanning in x direction";
	cin>>x;
	cout<<"\n""Enter the maximum value of scanning in y direction";
	cin>>y;
	cout<<"\n""Enter the value of distance between the grids in x axis";
	cin>>k;
	cout<<"\n""Enter the value of distance between the grids in y axis";
	cin>>l;
	cout<<"\n""Enter the value of deltax";
	cin>>a;
	cout<<"\n""Enter the value of deltay";
	cin>>b;
	cout<<"\n""Enter the value of p";
	cin>>p;
	cout<<"\n""Enter the value of q";
	cin>>q;
	selection();
	getch();

        return 0;
}

hehe noob question:P
what does it mean when u declare variables outside of the struct?
struct data
{
int x,y;
double s,w,e,d;
}d[5000],f[5000]; <<<< ?

It instantiates two arrays, d with 5,000 elements and f with 5,000 elements.

I think it's important to note that the 2 arrays are of type "data".

struct data
{
int x,y;
double s,w,e,d;
}d[5000],f[5000];

is equivalent to

struct data
{
int x,y;
double s,w,e,d;
};

data d[5000], f[5000];
This article has been dead for over six months. Start a new discussion instead.