有谁知道为什么下面的代码不适用于char
s?它适用于int
s 但是当我想用来char
初始化结构时,它会失败并给出如下警告:
warning: assignment makes integer from pointer without a cast
我不知道这个警告是什么意思。
#include <stdio.h>
#include <stdlib.h>
struct complex {
int re;
int im;
char name;
};
struct complex initialize (int k, int l, char nazwa)
{
struct complex x;
x.re = k;
x.im = l;
x.name= nazwa;
return x;
}
int main ()
{
struct complex e;
struct complex f;
int a;
int b;
char o;
int c;
int d;
char p;
a=5;
b=6;
o="t";
e = initialize (a, b, o);
c=8;
d=3;
p="u";
f=initialize (c, d, p);
printf("c1 = (%d,%d)\nc2 = (%d,%d)\n name 1=%s name 2=%s\n", e.re , e.im, f.re, f.im, e.name, f.name);
return 0;
}