C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 20th, 2003, 10:48 AM
kl365 kl365 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 29 kl365 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 9 m 45 sec
Reputation Power: 0
Bus Error when trying to read a character

I'm helping my friend debug an assignment for school and he's only allowed basic C functions and variables, no arrays. I haven't been able to figure out why a bus erro occurrs right after the scanf statement.

The program executes fine until then, then once i press enter it crashes. I know that characters are basic variable types represented by "%c" and unlike chars, we do have to use the dereference operator. I thought it had something to do with that, trying to write a char to an address, but i can't get it. probably something really simple i just haven't clued into yet.
thanks.


Code:
  printf("Enter salary details(End of data enter position as E:\n");
  printf("Enter position(W or S or E): ");
  scanf("%c", &employeeChoice);
         
  while(employeeChoice != 'E' || employeeChoice != 'e')
  {
    printf("Enter number of years of Service: ");
    scanf("%d", &numYears);
       

Reply With Quote
  #2  
Old November 20th, 2003, 11:27 AM
kl365 kl365 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 29 kl365 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 9 m 45 sec
Reputation Power: 0
figured it out.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Bus Error when trying to read a character

Developer Shed Advertisers and Affiliates



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap