没有声明Null?
我的代码:
// Include necessary libraries
#include <cstdlib> // Exits
#include <iostream> // I/O
#include <cstring> // String functions
using namespace std;
int main(int argc, char *argv[])
{
//Declare local Constants and Variables
const char SOKINP[19] = "23456789TtJjQqKkAa"; // Valid Input Characters
char acCards [5]; // Array to hold up to five cards (user input)
bool bErr; // Loop on Error (Calculated)
int i, // Loop variable (Calculated)
iNbrCrd, // Number of Cards 2-5 (user input)
iNAces, // Number of Aces (Calculated)
iTS; // Total Score (Calculated)
...
for (i=0;i<iNbrCrd;i++){
do {
cout << "Enter Card #" << i << " (2-9,t,j,q,k or a) >";
cin >> acCards[i];
cout << endl;
bErr = (strchr(SOKINP, acCards[i]) == null) ? true : false; // *ERROR*
} while (bErr);
}
return EXIT_SUCCESS;
}此范围内未声明错误“null”。
我如何声明'null'?我试过包括其他几个图书馆。我使用的是Dev C++ v5.4.2
谢谢,~d
发布于 2013-09-29 04:47:11
不是null。所有的大写都是NULL。如果编写NULL不起作用,则可以使用
#define NULL 0发布于 2013-09-29 04:51:03
使用NULL而不是Null。
如果您使用它初始化指针,并且使用C++11,则使用nullptr。
尽管NULL用于分配指针(即使NULL不是指针类型,而是整数),但在以下情况下可能会遇到问题:
void func(int n);
void func(char *s);
func( NULL ); // guess which function gets called?有关更多详细信息,请参阅这
https://stackoverflow.com/questions/19074470
复制相似问题