c - 变量 "struc"周围的堆栈已损坏

标签 c stack

所以我遇到了 Visual Studio 2013 的问题 此代码显示没有编译错误,但显示调试错误

Stack around the variable 'Joueur' was corrupted.

这是代码:

==源.cpp

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

int main()
{
    Personne Joueur[2];
    printf("***** Bienvenue ***** \n \n \n");
    int k ;
    for (k = 0; k < 3; k++)
    {
        printf("Bonjour Joueur %d :\n", k+1);
        printf("Nom: ");
        fgets(Joueur[k].Nom,50,stdin);
        printf("Votre nom est: %s", &Joueur[k].Nom);
        printf("\n \n");
    }
    return 0;
}

== Header.h

typedef struct Personne Personne;
struct Personne
{
    char Nom[1500];
    char Prenom[1500];
    int Age;
    int Tel;
    double Moy;
};

最佳答案

改变 Personne Joueur[2]; -> Personne Joueur[3];

您没有足够的内存来容纳 2 个以上的结构。

关于c - 变量 "struc"周围的堆栈已损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38559236/

相关文章:

C, 变量 f1 周围的堆栈被破坏

java - 为什么堆栈使用数组为什么不使用链表

C代表困惑?声明顺序导致段错误

使用指针从 Fortran 调用 C 函数

c - 一个简单的字符设备驱动程序

c - jemalloc、mmap 和共享内存?

java - 如何在 Java 中将堆栈跟踪打印到标准输出以进行调试?

C++11 堆栈分配与 Unique_Ptr

c - C中堆栈上的跟踪函数

c++ - C++ 中的 sprintf?