#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2006
    Location
    America
    Posts
    146
    Rep Power
    9

    Question 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 09:39 PM.

IMN logo majestic logo threadwatch logo seochat tools logo