计划接收信号SIGSEGV,分割过错。调试时 [英] Program received signal SIGSEGV, Segmentation fault. when debugging

查看:450
本文介绍了计划接收信号SIGSEGV,分割过错。调试时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果调试我的code然后我得到计划接收信号SIGSEGV,分割过错。这里是我的code -

If I debug my code then I get "Program received signal SIGSEGV, Segmentation fault." Here is my code-

#include <stdio.h>
#include <conio.h>
#include <string.h>

int main()
{
    struct term
    {
        char* name;
        long int id;
        float term_gpa;
    };
    struct term *term_ptr, student;

    term_ptr = &student;

    strcpy( term_ptr->name,"niton");
    term_ptr->id = 942044;
    term_ptr->term_gpa = 3.75;

    printf("Name : %s",term_ptr->name);
    printf("Name : %s",student.name);

    getch();
    return 0;
}

我得到17行这个错误请帮助我!对不起,我的英语不好。

I get this error on line 17. Please help me! Sorry for my bad English.

推荐答案

您需要为 term_ptr-&GT分配内存;名称

这篇关于计划接收信号SIGSEGV,分割过错。调试时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆