[HELP] segmentation fault (core dumped) error menu

Shout-Out

User Tag List

Results 1 to 2 of 2
  1. #1
    klamor's Avatar Active Member
    Reputation
    30
    Join Date
    Mar 2007
    Posts
    323
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [HELP] segmentation fault (core dumped) error

    Hey everyone, I was wondering if someone could take a look at my program and see if they can figure out why i'm getting this error during runtime. I believe the error is thrown because i'm accessing an illegal memory location (ie. doesn't exist), but I can't seem to find where. If anyone has any suggestions, they would be greatly appreciated.

    Code:
    #include<stdio.h>
    void read (int[20]);
    void print (int[20]);
    
    int main(void){
        int numbers[20];
        read(numbers);
        print(numbers);
    
    return 0;
    }
    
    void read (int numbers[20]){        //Reads input and saves to an array
        int num, j;    
        printf("Please enter 20 numbers between 10 and 100.\n");
        for (j =0; j<20; j++){
            scanf("%d", num);
            numbers[j] = num;
        }
    }
    
    void print (int numbers[20]){        //Prints the numbers of the array as long as they aren't
        int j, n, flag =0;                      //of previous numbers.
        for(j =0; j<20; j++){
            if(j>0){
                for(n =j; n>0; n--){
                    if(numbers[j]==numbers[n])
                        flag=1;
                }
            }
            if (flag==0)
                printf("%d, ", numbers[j]);
            flag = 0;
        }
    }


    [HELP] segmentation fault (core dumped) error
  2. #2
    giggling's Avatar Member
    Reputation
    1
    Join Date
    Jul 2010
    Posts
    9
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are passing 'num' to scanf instead of '&num'

Similar Threads

  1. Help me with these Vista errors please!
    By anthonyninja1 in forum World of Warcraft Emulator Servers
    Replies: 0
    Last Post: 06-24-2008, 06:44 AM
  2. [help]Nvidia GeForce 8800 GT Error
    By BrantX in forum Gaming Chat
    Replies: 4
    Last Post: 06-14-2008, 12:08 AM
  3. need help with 2 core edits
    By z3ro379 in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 05-30-2008, 06:33 PM
  4. [Help] new Ascent core
    By xaverz in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 05-23-2008, 11:06 AM
  5. [HELP!!!] Logging into game server error...
    By Jayson22 in forum World of Warcraft Emulator Servers
    Replies: 0
    Last Post: 05-18-2008, 03:07 PM
All times are GMT -5. The time now is 10:43 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search