Chinaunix

标题: 请教下linux下c的参数调用为什么调用char type报错呢 [打印本页]

作者: black-hat    时间: 2010-12-23 08:53
标题: 请教下linux下c的参数调用为什么调用char type报错呢
[root@localhost c]# cat one-canshu.c
#include <stdio.h>
void hu_te(char test,char test1)
{
        printf ("mobile=%c\nnumber=%c\n",test,test1);
}
int main(void)
{

        char n,qq;
        n=tt;
        qq=hao;
        hu_te(n,qq);
        return  0;
}
[root@localhost c]# gcc -Wall -o one-canshu one-canshu.c
one-canshu.c: In function ‘main’:
one-canshu.c:10: error: ‘tt’ undeclared (first use in this function)
one-canshu.c:10: error: (Each undeclared identifier is reported only once
one-canshu.c:10: error: for each function it appears in.)
one-canshu.c:11: error: ‘hao’ undeclared (first use in this function
用int 传都没问题。

请各位高手指点一下,小弟初学c谢谢。
作者: curious_cat    时间: 2010-12-23 09:05
有点被雷到了!   
char n,qq;
n和qq是char型的,应该这样赋值
n= ‘t';
qq='t';
作者: black-hat    时间: 2010-12-23 22:07
oh my god 的忘记了 ,char 需要加引号。对不起了大家 我一定好好学习。
作者: bangziFnst    时间: 2010-12-24 16:41
加油!




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2