
November 20th, 2003, 10:48 AM
|
|
Registered User
|
|
Join Date: Nov 2003
Posts: 29
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);
|