non-pointer type `char' from NULL的问题
#include <iostream>
using namespace std;
char *strncat(char *destination, const char *source, int n);
int main()
{
char *str1=new char[256];
char *str2=new char[256];
cout << "Input string1 and Press Enter: " << endl;
cin.getline(str1,256,'\n');
cout << "Input string2 and Press Enter: " << endl;
cin.getline(str2,256,'\n');
strncat(str1,str2,2);
cout << "The result is:" << endl << str1;
return 0;
}
char *strncat(char *destination, const char *source, int n)
{
char *original=destination;
int i=0;
while (*destination)
destination++;
while ((i++<n) && (*destination++=*source++))
;
if (i>n)
*destination=NULL;
return original;
}
g++ strncat.cpp -g -o strncat
出现警告:
strncat.cpp: In function `char* strncat(char*, const char*, int)':
strncat.cpp:27: warning: assignment to non-pointer type `char' from NULL
strncat.cpp:27: warning: argument to non-pointer type `char' from NULL
第27行是:*destination=NULL;
这个警告是什么意思啊?