Quantcast
Viewing all articles
Browse latest Browse all 22056

segmentation fault (core dumped) gcc ubuntu

I was trying to make a simple function to make a group of number that user enters them, using pointer of pointer but i keep getting this error and its hard to tell where the problem is, if there any other option to use something else that tells me where the problem is instead of this weird error.

#include <stdio.h>void BuildGroub(int** group,int* count){    int i=0;    int j;    printf("Enter the size of the group \n");    scanf("%d", &*count);    while(*count != 0){        printf("Enter the %d number of the group:\n", i);        j=0;        scanf("%d", &**(group+i));        while(**(group+i)!=**(group+j)){            j++;        }        if(j==i){            i++;            count--;        } else{            printf("you have already entered this number please try again: \n");        }    }}int main(){    int count;    int group[100];    int *groupptr = &group;    BuildGroub(&groupptr,&count);    for(int i=0;i<count;i++){        printf("%d, ", group[i]);    }    return 0;}

Viewing all articles
Browse latest Browse all 22056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>