我试图在我的.c源文件代码中使用ctime,但由于某种原因,ctime会出现几个语法错误。此外,我甚至无法关闭Visual Studios或ctime选项卡,因为我一直收到错误说"操作无法完成。没有足够的存储空间来完成此操作"。此外,当我再次尝试编译我的代码时,我被用来保存文件,但保存按钮根本不起作用。我基本上卡住我的VS窗口,没有办法删除ctime尝试别的东西。我该怎么做才能解决这个问题?
编辑:即使我切换到time.h,这是试图保存的文件
c:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Community \ VC \ Tools \ MSVC \ 14.11.25503 \ include \ ctime。*
ctime语法:
// ctime standard header
#pragma once
#ifndef _CTIME_
#define _CTIME_
#include <yvals.h>
#include <time.h>
#ifndef RC_INVOKED
_STD_BEGIN
using _CSTD clock_t; using _CSTD size_t;
using _CSTD time_t; using _CSTD tm;
using _CSTD asctime; using _CSTD clock; using _CSTD ctime;
using _CSTD difftime; using _CSTD gmtime; using _CSTD localtime;
using _CSTD mktime; using _CSTD strftime; using _CSTD time;
_STD_END
#endif /* RC_INVOKED */
#endif /* _CTIME_ */
/*
* Copyright (c) by P.J. Plauger. All rights reserved.
* Consult your license regarding permissions and restrictions.
V6.50:0009 */
错误:
-identifier&#34; namespace&#34;未定义第9行
-PCH警告:标题停止需要在全局范围内。未生成第17行的IntelliSense PCH文件
-syntax error:identifier&#39; std&#39;第9行
-syntax错误:&#39;;&#39;第9行
-found&#39; {&#39;在文件范围(缺少函数头?)第9行
-syntax错误:&#39;}&#39;第15行
- 找到了文件的结尾(我的原始.c文件)第75行(我只有74行)
我目前的代码:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <time.h> //Edited from #include <ctime>
void dealCard(char hand[][5]);
//Global variables
char cards[5][14] =
{
{ 'A', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'K', 'Q', 'J' },
{ 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C' },
{ 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D' },
{ 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H' },
{ 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S', 'S' }
};
char p1Hand[2][5] =
{
{ NULL, NULL, NULL, NULL, NULL },
{ NULL, NULL, NULL, NULL, NULL }
};
char p2Hand[2][5] =
{
{ NULL, NULL, NULL, NULL, NULL },
{ NULL, NULL, NULL, NULL, NULL }
};
char p1Name[15], p2Name[15];
int main()
{
srand(time(0));
printf("-------------\n POKER\n-------------\n\n[CHARACTERS AFTER A SPACE WILL BE IGNORED]\n");
printf("\nPlease enter player 1's name: ");
scanf(" %[^\n]%*c", &p1Name);
printf("%s", p1Name);
getchar();
return 0;
}
void dealCard(char hand[][5])
{
int x, y;
bool added = false;
reset:
//Chooses a random card from the deck
x = (rand() % 4) + 1;
y = rand() % 14;
//Adds the card to the hand
if (cards[x][y] != NULL)
{
for (int i = 0; added == false; i++)
{
if (hand[0][i] == NULL)
{
added = true;
hand[0][i] = cards[0][y];
hand[1][i] = cards[x][y];
cards[x][y] = NULL;
}
}
}
else
{
goto reset;
}
}