小编use*_*885的帖子

连续相同的"printf"调用产生不同的输出

我连续调用printf函数,第一个printf写入必须写入的内容,第二个printf只写无效值,我猜一些错误.

"LOC"的类型由我定义,变量"i"在调用后不会改变.我检查了双倍的printf和我给它的值之间的任何差异.

i=2;
printf("x = %f,y = %f,z = %f\n",(*LOC)[0].ProjectionPoints[i].X,(*LOC)[0].ProjectionPoints[i].Y,(*LOC)[0].ProjectionPoints[i].Z); /* Prints perfectly */
printf("x = %f,y = %f,z = %f\n",(*LOC)[0].ProjectionPoints[i].X,(*LOC)[0].ProjectionPoints[i].Y,(*LOC)[0].ProjectionPoints[i].Z); /* Shows some errors and values are "0" */
Run Code Online (Sandbox Code Playgroud)

首先printf写道

x = -10.000000,y = -8.000000,z = -10.000000
Run Code Online (Sandbox Code Playgroud)

第二个printf写道

x = 0.000000,y = 0.000000,z = -1.#QNAN0
Run Code Online (Sandbox Code Playgroud)

即使定义变量const也不会改变任何东西.

我的编译器是: MS Visual C++ 2012

看完评论后;

typedef struct {
P3C_Point *ProjectionPoints;
uint Distance,LayerID,NumberOfPoints,ModelID;} P3C_LayerOnCurtain;
/* and */
P3C_LayerOnCurtain **LOC = P3C_Compile(Stream);
/* when I try printf in P3C_Compile it has no …
Run Code Online (Sandbox Code Playgroud)

c io double printf

1
推荐指数
1
解决办法
277
查看次数

标签 统计

c ×1

double ×1

io ×1

printf ×1