I call my program and it is to read a bunch fo integers from the standard input
int main() {
int* s;
derp(s);
return 0;
}
void derp(int *size) {
scanf("%d", size);
}
why is this code causing a segmentation fault?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What does
spoint to? To random garbage memory since its not initialized. You should do this instead:or you could allocate storage space using
malloc: