警告C4047: [英] warning C4047:

查看:138
本文介绍了警告C4047:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,这只是一个警告,但任何人都可以向我解释这个警告是什么:


警告C4047:''='':''unsigned int' '间接水平与''无效*'不同


#include< stdio.h>

void swap(int * x,int * y);

int main()

{

int x [2] = {1,6},y [2] = { 1,10};

printf(在函数交换之前,x =%d和y =%d \ n \ nn,x,y);

swap(& x,& y);

printf("函数交换后,x =%d和y =%d \ n \ n",x,y );

返回0;

}

void swap(int * x,int * y)

{

int temp = * x;

* x = * y;

* y = temp;

}

Hello, It''s just a warning, but can anybody explain to me what this warning is:

warning C4047: ''='' : ''unsigned int '' differs in levels of indirection from ''void *''

#include <stdio.h>
void swap(int *x, int *y);
int main()
{
int x[2]={1,6}, y[2]={1,10};
printf("Before the function swap, x = %d and y = %d\n\n", x, y);
swap(&x, &y);
printf("After the function swap, x = %d and y = %d\n\n", x, y);
return 0;
}
void swap(int *x, int *y)
{
int temp = *x;
*x = *y;
*y = temp;
}

推荐答案

io **************** @ web.de (isxyos)写道:
io****************@web.de (isxyos) wrote:
你好,这只是一个警告,但任何人都可以向我明白这个警告是什么:

警告C4047:''='':''unsigned int''的间接等级与''void *'不同

#include< stdio.h>
void swap(int * x,int * y);
int main()
{
int x [2] = {1 ,6},y [2] = {1,10};
使这个:int x = 6,y = 10;

printf("在函数交换之前,x =%d和y =%d \ n \ n", x,y);
swap(& x,& y);
printf("函数交换后,x =%d和y =%d \ n \ n", x,y);
返回0;
}
或者,如果x和y必须是数组,则在printf()s中将x,y更改为* x,* y,

并将交换(& x,& y)更改为swap(x,y);

唉,您为x [0]和y提供的值相同[0],你是否b / b
你根本不会调用swap()...

void swap(int * x,int * y )
{
int temp = * x;
* x = * y;
* y = temp;
}
Hello, It''s just a warning, but can anybody explain to me what this warning is:

warning C4047: ''='' : ''unsigned int '' differs in levels of indirection from ''void *''

#include <stdio.h>
void swap(int *x, int *y);
int main()
{
int x[2]={1,6}, y[2]={1,10}; Make this: int x = 6, y = 10;
printf("Before the function swap, x = %d and y = %d\n\n", x, y);
swap(&x, &y);
printf("After the function swap, x = %d and y = %d\n\n", x, y);
return 0;
} Or, if x and y had to be arrays, change x, y to *x, *y in the printf()s,
and change swap( &x, &y ) to swap( x, y );
Alas, with the identical values you supplied for x[0] and y[0], you
won''t notice if you''d invoced swap() at all...
void swap(int *x, int *y)
{
int temp = *x;
*x = *y;
*y = temp;
}




-

6 * 9 = 42(基数13)



--
6 * 9 = 42 (base 13)


isxyos< io ****** **********@web.de>写道:
isxyos <io****************@web.de> wrote:
你好,这只是一个警告,但任何人都可以向我解释这个警告是什么:
警告C4047:''='':''unsigned int''间接级别与''void *''不同
#include< stdio.h>
void swap(int * x,int * y);
int main()
{
int x [2] = {1,6},y [2] = {1,10};
printf("在函数交换之前,x =%d和y = %d \ n \\ nnn,x,y);
swap(& x,& y);
printf("函数交换后,x =%d和y = %d \ n \\ nn,x,y);
返回0;
}
void swap(int * x,int * y)
{
int temp = * x;
* x = * y;
* y = temp;
}
Hello, It''s just a warning, but can anybody explain to me what this warning is: warning C4047: ''='' : ''unsigned int '' differs in levels of indirection from ''void *'' #include <stdio.h>
void swap(int *x, int *y);
int main()
{
int x[2]={1,6}, y[2]={1,10};
printf("Before the function swap, x = %d and y = %d\n\n", x, y);
swap(&x, &y);
printf("After the function swap, x = %d and y = %d\n\n", x, y);
return 0;
}
void swap(int *x, int *y)
{
int temp = *x;
*x = *y;
*y = temp;
}




Don''知道错误信息究竟是什么意思,是

你确定你已经为你发布的程序得到了它(我看不到任何

任何'''' void *''也不是整个'unsigned int''程序...)?但问题是显而易见的:你宣称x和y是

的数组,每个都是两个整数,但在下面你一直对待它们

好​​像它们是简单的整数。因此,要么改变你的程序,要么将它们声明为简单的整数,或者将每个

附加到其他地方,如果你的意思是数组的第一个或第二个元素。


问候,Jens

-

_ _____ _____

| || _ _ || _ _ | Je *********** @ physik.fu-berlin.de

_ | | | | | |

| | _ | | | | | | http://www.physik.fu-berlin.de/~toerring

\ ___ / ens | _ | homs | _ | oerring



Don''t know what the error message is exactly supposed to mean, are
you sure you got it for the program you posted (I can''t see neither
any ''void *'' nor an ''unsigned int'' in the whole program...)? But
the problem is obvious: you''re declaring x and y to be arrays of
two integers each but in the following you consistently treat them
as if they were simple integers. So either change your program so
that they are both declared to be simple integers or append every-
where else if you mean the first or the second element of the array.

Regards, Jens
--
_ _____ _____
| ||_ _||_ _| Je***********@physik.fu-berlin.de
_ | | | | | |
| |_| | | | | | http://www.physik.fu-berlin.de/~toerring
\___/ens|_|homs|_|oerring


isxyos写道:

您好,这只是一个警告,但有人可以向我解释这个警告是什么:

警告C4047:''='':''unsigned int''在间接级别来自''void *''
void swap(int * x,int * y);
int main()
{
int x [2] = {1,6},y [2] = {1,10};
printf("在函数交换之前,x =%d和y =%d \ n \\ nn,x,y);


x和y不是''整数。

您认为应该打印什么?

swap(& x ,& y);


swap(x,y);


在此上下文中,x和y转换为指向它们的指针

各自的第一个元素。

printf(函数交换后,x =%d和y =%d \ n \ nn,x,y);
返回0;
}
void swap(int * x,int * y)
{
int temp = * x;
* x = * y;
* y = temp;
}

Hello, It''s just a warning, but can anybody explain to me what this warning is:

warning C4047: ''='' : ''unsigned int '' differs in levels of indirection from ''void *''

#include <stdio.h>
void swap(int *x, int *y);
int main()
{
int x[2]={1,6}, y[2]={1,10};
printf("Before the function swap, x = %d and y = %d\n\n", x, y);
x and y arent'' integers.
What do you think is supposed to be printed ?
swap(&x, &y);
swap(x, y);

In this context, x and y are converted to pointers to their
respective first elements.
printf("After the function swap, x = %d and y = %d\n\n", x, y);
return 0;
}
void swap(int *x, int *y)
{
int temp = *x;
*x = *y;
*y = temp;
}



#include< stdio.h>


void swap(int * x, int * y);


int main(无效)

{

int x [2] = {1,2} ,y [2] = {3,4};


printf("在函数交换之前,x [0] =%d和y [0] =%d \ n",

x [0],y [0]);

printf("在函数交换之前,x [1] =%d和y [1] =%d \ n \ n",

x [1],y [1]);

swap(x,y);

swap(x + 1,y + 1);

printf("函数交换后,x [0] =%d和y [0] =%d \ n,

x [0],y [0]);

printf(" After t他函数交换,x [1] =%d和y [1] =%d \ n \ n",

x [1],y [1]);

返回0;

}


void swap(int * x,int * y)

{

int temp = * x;


* x = * y;

* y = temp;

} b / b

pete


#include <stdio.h>

void swap(int *x, int *y);

int main(void)
{
int x[2]={1,2}, y[2]={3,4};

printf("Before the function swap, x[0] = %d and y[0] = %d\n",
x[0], y[0]);
printf("Before the function swap, x[1] = %d and y[1] = %d\n\n",
x[1], y[1]);
swap(x, y);
swap(x + 1, y + 1);
printf("After the function swap, x[0] = %d and y[0] = %d\n",
x[0], y[0]);
printf("After the function swap, x[1] = %d and y[1] = %d\n\n",
x[1], y[1]);
return 0;
}

void swap(int *x, int *y)
{
int temp = *x;

*x = *y;
*y = temp;
}

--
pete


这篇关于警告C4047:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆