为什么char型数组不能初始化???大侠帮忙看看
大侠帮忙瞧瞧为什么这句char s[100]=NULL;初始化不对吗??数组的初始化不就是=NULL的吗???--------------------Configuration: 统计字符串 - Win32 Debug--------------------
Compiling...
main.cpp
E:\Windos32\统计字符串\main.cpp(7) : error C2440: 'initializing' : cannot convert from 'const int' to 'char [100]'
There are no conversions to array types, although there are conversions to references or pointers to arrays
执行 cl.exe 时出错.
统计字符串.exe - 1 error(s), 0 warning(s)
#include <iostream.h>
#include <stdio.h>
void main()
{
cout<<"enter a string:"<<endl;
int a,b,c,i;
char s[100]=NULL;
a=b=c=i=0;
gets(s);
for(i=0;i<100;i++)
{
if(s[i]=='\0')
break;
if(s[i]>='0' && s[i]<='9')
a++;
else if(s[i]>='A'&&s[i]<='Z' || s[i]>='a'&&s[i]<='z')
b++;
else c++;
}
cout<<"SZ="<<a<<endl;
cout<<"ZF="<<b<<endl;
cout<<"FH="<<c<<endl;
getchar();
}