C 高分列表调试错误
C++ Highscore List Debug Error
编辑代码:我现在能够在文件中写入时钟时间,但是问题是,这不是时钟时间。它写入奇怪的数字,例如00f3d ..等等。我不知道是否到期,因为时钟的时间在字符串格式时包含一个结肠,示例:0:12
// Used for Highscores
struct highscore
{
char name[10];
int zombiesKilled;
char Date[10];
char *clock[10];
};
void highscoreBoard(int option, int zombKilled)
{
int quanity = 0;
int playerScore = 0; // the in Results for Highscores
FILE *streaming;
highscore data[10];
char *newClock = new char[clockData.clockTime.length() + 1];
strcpy(newClock,clockData.clockTime.c_str());
switch (option)
{
}
您的highscore
结构中有string clock
。string
类型的对象不适合直接从内存中写入文件,因为它们可能包含到内存其他部分的指针。
这里有两个解决方案:要么像其他结构成员一样将clock
更改为char数组,要么不使用高分的二进制写作,请将文件写为文本(这更复杂,但导致了一个人类可读文件)。
您是否在创建文件后设置了文件权限?似乎将权限设置为没有读取,没有写,没有执行。
相关文章:
- C++为什么我的编译器成功了,但我的计算机给出了调试错误?
- 分段错误 .AnsiStringToUnicodeString 作为第一个调试错误行.杜比奥斯类等级制度
- 尝试在我的基类中启动线程时,Visual Studio 由于调试错误而中止我的程序
- OpenGL 调试 错误回调函数的 ID 参数是什么?
- 如何调试错误代码 77:cudaErrorIllegal地址当 cuda-memcheck 没有发现问题时
- 如何调试错误消息"abort() has been called"?
- Eclipse调试错误:没有此类文件或目录 n
- 调试错误,在C++中检测到堆损坏
- Qt:如何在QByteArray中调试错误的分配异常
- 尝试运行程序时会收到调试错误
- C 高分列表调试错误
- 我的C++函数不断收到调试错误。我不确定我做错了什么
- 使用 GDB 在 main() 之前调试错误
- c++中的调试错误
- 多线程效率低下:调试错误共享
- 调试错误.已调用R6010中止()
- C++的调试错误真的很令人沮丧
- SDL 项目的调试错误"没有可用于 main() 的源代码"
- 调试错误R6010-已调用abort()
- 程序在Visual Studio Community 2015中执行后,它会显示调试错误