Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts

    segmentation fault

    how come i get segmentation faults on this code
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    float bonus(void);
    
    void main() {
            float b;
            printf("Enter a # to be incremented: ");
            b=bonus();
            printf("The incremented is now %.2f",b);
    }
    float bonus(void) {
            float i;
            scanf("%f",i);
            return(i+1);
    }

  • #2
    New Coder
    Join Date
    Jun 2002
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts
    maybe cauz you forgot the ampersand round i in scanf. Might be the reason.

  • #3
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i owe you my life i am stupid, but i will take you on in javascript, mabey


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •