The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Why not a segmentation fault?? lagigliaivan High Level Programming 22 05-21-2008 11:07 AM
segmentation fault rockgal High Level Programming 8 12-05-2006 12:16 PM
segmentation fault wojtyla High Level Programming 3 02-19-2005 02:53 PM
Segmentation fault jshaulis AIX 1 06-01-2004 04:16 PM
segmentation fault omran High Level Programming 2 08-01-2003 08:19 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-19-2006
compbug compbug is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 26
Segmentation Fault

hello all,

I tried a program on an array to intialise array elements from the standard input device.it is an integer array of 5 elements.but after entering the 4th element it throws a message called "Segmentation Fault" and returns to the command prompt without asking for the 5th element.

why is it so?
  #2 (permalink)  
Old 04-19-2006
amro1 amro1 is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 105
Let me guess

are you counting from 1 to 5 or from 0 to 4 ?
  #3 (permalink)  
Old 04-21-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Good question. Remember that when you work with an array of size 5 in C, you have locations array[0]...array[4].
  #4 (permalink)  
Old 04-21-2006
compbug compbug is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 26
sorry guys Petty mistake

thanks for your time guys.

I had done a petty mistake in scanf.I tried to accept the input like this
for(i=0;i<5;i++)
scanf("%d", a[i]); The mistake.

I was supposed to give "&a[i]" .


thanks for your time pals.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:24 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0