Dev C Segmentation Error Question

Asked 2 years ago, Updated 2 years ago, 111 views

I just started coding. I haven't been able to input a string and print it out yet, so I was going to try DevC I created the code and entered it. But the launcher didn't respond I turned on the debugging and it says segmentation error.

Please reply easily

This is the code

#include <stdio.h>
#include <stdlib.h>

    int main() 
{       
    char* q;

    printf("Type your name.\n");
    scanf("%s", &q);
    printf("Your name is: %s\n", q);

    return 0; 
} 

segmentation-fault c

2022-09-20 19:59

1 Answers

char q[1024];

// ...
scanf("%s", q);
// ...

You have to do it like this.

The code of the questioner is the same as the room key without preparing a room for a person. People came from scanf and they couldn't get in and made a claim when they tried to put it in the key.

It's easy, right?


2022-09-20 19:59

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.