c语言编译中光标错位,关于c的printf错位问题。。。

关于c的printf错位问题。。。

coursework2的作业要求写一个程序从一个stops.txt里面读取自行车站点的信息,在命令行输入起点和终点的经度纬度,计算出离起点最近的stops和终点的stops,最后再print出来。

正确的print应该像是这个样子的:

21c92f7342edc52acb5684b0b88bdcec.png程序代码:F:\Introduction to Programming\bikehelper>bikehelper 121.593567 29.86417 121.589

78 29.88098

Starting from 121.593567 29.864170

Walk North-West to haoyangguangshangwu at 121.593560 29.864180

Cycle North to tiyuguanbei at 121.589600 29.879370

Walk North to your destination at 121.589780 29.880980.

F:\Introduction to Programming\bikehelper>

我这一部分的代码是酱紫的:

21c92f7342edc52acb5684b0b88bdcec.png程序代码:...

printf("Starting from %lf %lf\nWalk ",location[1],location[2]);

direction(location[1],location[2],stops_info[stop_s].stop_longitude,stops_info[stop_s].stop_latitude);

printf(" to %s at %lf %lf\nCycle ",stops_info[stop_s].stop_name,stops_info[stop_s].stop_longitude,stops_info[stop_s].stop_latitude);

direction(stops_info[stop_s].stop_longitude,stops_info[stop_s].stop_latitude,stops_info[stop_d].stop_longitude,stops_info[stop_d].stop_latitude);

printf(" to %s at %lf %lf\nWalk ",stops_info[stop_d].stop_name,stops_info[stop_d].stop_longitude,stops_info[stop_d].stop_latitude);

direction(stops_info[stop_d].stop_longitude,stops_info[stop_d].stop_latitude,location[3],location[4]);

printf(" to your destination at %lf %lf.\n",location[3],location[4]);

exit(0);

}我在我自己的WinXP下的dev下测试是完全正常的,但是在Ubuntu下测试就会问题。

于是到学校的centos下测试,学校的centos属于虚拟主机那种,在user目录下printf是完全正常,但是如果是在user/test文件夹下测试就又会出现问题。

问题就如图片中显示的一样。。。。但是如果将编译结果拷贝出来运行,又不会出现这样子的错位问题。。。

div>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值