昨天用codeblocks的时候出现了奇怪的warning,并且在语法上,我查了,printf的用法没有错,程序运行也符合预期,但是作为轻度强迫症这些warning还是让我难受,同时也令我摸不着头脑,之后我有使用dev c++编译了一下
文件,发现没有任何warning。我的dev c++和codeblocks用的是同一个编译器,这就给我整晕了。要是有人知道这是怎么回事,还望不吝赐教
#include <stdio.h>
#include <string.h>
#include<stdint.h>
struct student
{
int score[4];
char name[5];
long long int IDnum;
double avg;
};
void structAssign(void* src,void* dst,uint32_t size)
{
uint8_t* temp = (uint8_t*)src;
for(int i =0; i!=size; i++)
{
*(uint8_t*)dst=*temp;
dst++;
temp++;
}
}
int main()
{
struct student temp = {{1,2,3,4},"??",12123,12.5};
//temp->name=b;
struct student temp2 = {{4,2,4,7},"?!",15123,72.445};
structAssign(&temp,&temp2,sizeof(struct student));
printf("%d %s %lld %.3f",temp2.score[0],temp2.name,temp2.IDnum,temp2.avg);
//code::blocks在这里报warning,程序可以正常运行,但是dev c++中不会报任何错误
}