Hello again guys!
i have a simple question how to promt user to enter a number for example 444 or whatever and for c to print it as a 9 digit number, so if its 444 c would print it as 000000444?

any help would be greatly appriciated.,

thanx!

Recommended Answers

All 4 Replies

Do you want to do it just so you could justify it to the right? If so you could use this:

int i=444;
printf("%9d",i);

It won't include any zeroes at the beginning but it'll be right justified.

int n = 444;
printf("%09d", n);

More examples here.

commented: %09d- ofcourse! *whacks self* +1

Thanx a lot guys!

int i=444;
printf("9%d",i);

commented: Eh? +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.