Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 1st August 2008
jgroch jgroch is offline
Port Guard
Join Date: Jul 2008
Posts: 14
Default C 2D arrays

I'm trying to learn C and I'm a little embarrassed to ask, but I've spent more time trying to find an answer than I think should be necessary without finding out why, so I'll ask.

Why does the following create a segmentation fault when run?

int main() {
	int a[1000000][1000000];
	a[0][0] = 0;
As I understand it, seg faults mean I'm trying to access areas of memory that I shouldn't. So I'm guessing I'm not initializing an array properly. Or is it something to do with dimensions being to large?

Any help would be appreciated.
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic Perl arrays question stukov Programming 12 18th November 2008 08:44 PM
How to vectorize a function for numpy arrays in Python kasse Programming 0 26th August 2008 12:12 PM
ksh arrays mtx Programming 11 7th May 2008 10:00 AM

All times are GMT. The time now is 06:28 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick