
April 12th, 2007, 08:17 PM
|
 |
Contributing User
|
|
Join Date: Jun 2006
Location: America
Posts: 146
Time spent in forums: 1 Day 8 h 8 m 58 sec
Reputation Power: 7
|
|
Darwin bus error
Hi, I'm a bit new to unix so please be patient. I wrote a very simple prgram in C that recieves input from the user and performs a simple operation. Here's the code:
Code:
#include <stdio.h>
int main() {
int a, b, c;
printf("Enter the first value: ");
scanf("%d", &a);
printf("Enter the second value: ");
scanf("%d", &b);
c = a + b;
printf("%d + %d = %d\n", a, b, c);
return 0;
}
This should work perfectly but whenever I hit enter, after entering both values, I get an error that says "bus error". And sometimes "segmentation fault". What is this? What can I do to make it work?
Thanks
Last edited by RDG : April 12th, 2007 at 08:39 PM.
|