所以我遇到了 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/