我正在学习 C 中的函数指针和线程。以下代码将创建一个线程,该线程将从用户那里读取字符串。然后它将打印用户在主线程上输入的名称。但我得到了分段错误:11
#include<pthread.h>
#include<stdio.h>
int agelimit;
char *string1, *string2;
void *getName();
//void (*getAge)();
main(){
    pthread_t thread1,thread2;
    string1 = malloc(1000);
    //scanf("%s",string0);
    pthread_create(&thread1, 0, getName, 0);
    //pthread_create(&thread2, 0, getAge, 0);
    sleep(10);
    printf("name is %s age is",string1);
}
void *getName(){
    int x;
    printf("enter name:");
    scanf("%s",&string1);
}