简体   繁体   中英

formatting printf statement in cpp file

I have a cpp file within an xcode application, but am having trouble formatting the printf correctly.

My code is:

b2Vec2 axisA = b2MulT(xfA.R, m_axis);
printf("axis A = XXX", axisA);

I need to know what to put in XXX to print out the value of the 'axisA' variable.

Thanks

Printf accepts only plain data types, so you need to break it down:

printf("axis A = (%f,%f)", axisA.x, axisA.y);

or

printf("axis A = (%g,%g", axisA.x, axisA.y);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM