Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

pointers - C: Which character should be used for ptrdiff_t in printf?

Which character should be used for ptrdiff_t in printf?

Does C standard clearly explains how to print ptrdiff_t in printf? I haven't found any one.

int a = 1;
int b = 2;

int* pa = &a;
int* pb = &b;

ptrdiff_t diff = b - a;

printf("diff = %?", diff); // % what?
Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It's %td. See here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...