473,396 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

General Protection Error Again - Plz Help ASAP

6
When I try to compile the following code with N = 1024, "General Protection Exception" occurs, but wehn N < 20, there is no problem. I need N = 1024, what'll I do? Plz help anyone
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define L 20
  5. #define V 30
  6. #define O 2
  7. #define N 1024
  8.  
  9. struct Element
  10.  {
  11.     unsigned int c[L];
  12.     int value ;
  13.  };
  14.  
  15. struct Variable
  16.  {
  17.     struct Element e[V] ;
  18.     double y[V] ;
  19.     double f[O] ;
  20.  };
  21.  
  22. void initializeElement(struct Element*);
  23.  
  24. void main(void)
  25.  {
  26.     struct Variable *x ;
  27.     int i,j ;
  28.     x = (struct Variable*)malloc(sizeof(struct Variable) * N);
  29.  
  30.     if( x == NULL )
  31.       {
  32.         printf("not enough memory");
  33.         exit(0);
  34.       }
  35.  
  36.     for( i = 0 ; i < N ; i++ )
  37.         {
  38.           for( j = 0 ; j < V ; j++ )
  39.               {
  40.                  initializeElement(&(x[i].e[j]));
  41.                  x[i].y[j] = 0 ;
  42.               }
  43.  
  44.           for( j = 0 ; j < O ; j++ )
  45.               x[i].f[j] = 0 ;
  46.         }
  47.  }
  48.  
  49.  
  50. void initializeElement( struct Element *e)
  51.  {
  52.     int i, r ;
  53.     for( i = 0 ; i < L ; i++ )
  54.         {
  55.           r = rand() % 1000 ;
  56.           if( r < 500 )
  57.               e -> c[i] = 0 ;
  58.           else
  59.               e -> c[i] = 1 ;
  60.         }
  61.     e -> value = 0 ;
  62.  }
  63.  
Mar 5 '07 #1
2 1909
willakawill
1,646 1GB
vc6 is giving me no error with this code. I calculated that you are allocating 2.8mb here which should not cause a problem unless you are using a 1994 olivetti with 2mb ram. Probably not :)
Mar 5 '07 #2
akmkat
6
vc6 is giving me no error with this code. I calculated that you are allocating 2.8mb here which should not cause a problem unless you are using a 1994 olivetti with 2mb ram. Probably not :)
Thank you guys, U r right, no error in vc6/gcc !!!
Mar 18 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dharmesh Gandhi | last post by:
DB-Library Error 10007: General SQL Server error: Check messages from the SQL Server. CREATE PROCEDURE . ( @srvr varchar(50),
79
by: Klaus Bonadt | last post by:
In order to protect software from being copied without licence, I would like to use something like a key, which fits only to the current system. The serial number of the CPU or the current...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
by: Felix Kater | last post by:
Hi, when I need to execute a general clean-up procedure (inside of a function) just before the function returns -- how do I do that when there are several returns spread over the whole function?...
3
by: NickP | last post by:
Hi there, Today I try to compile an application of mine and I am getting a whole list of bizaar errors.... ------------------------------------------------ Error 1 The...
37
by: dmoran21 | last post by:
I am a mathematician trying to write a program in C to do some curve fitting. When I get to the point where I attempt to enter data in my arrays, I get a General Protection Exception error message....
3
by: charmeda103 | last post by:
I keep getting errors and i looked relooked I cant seem to see what wrong. from my code can see u where the errors are coming from. here are the error messages: 1.warning C4101: 'size' :...
2
by: subhasree | last post by:
Hi, I am a student of mathematics and quite new to programming in C. I am trying to write a code to construct an array which at every step has to compare the value of the current element with all...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.