Hi!

i dont know what is the difference between the 2 masks (the result
on visual c++ 2010 is the same):

Code:
sprintf(msg, "Number %2.2d",10);
sprintf(msg, "Number %02.2d",10);
and this mask too (what 0* means?)

Code:
sprintf(msg, "Number %0*d",10);
Thanks!!

2. Try numbers other than ten and you might just find out yourself.

3. Like what? i tried others too but with or without 0 (2.2 / 02.2) i got the same result. this is not a homework or something that i want you to do for me... If i'm asking here is because i really want to know the difference. So if you will say "try others to find yourself", please, don't answer my post, this is for people who want to learn and exchange experiences...

anyway, thank you!

And i still dont know the difference, so please, if anyone knows just tell me.

4. So did you actually try 100,1000,10000,100000 and so on?

If you want to learn, you do the typing, compiling, running the code, observing the results.
Then (and only then), do you post your code and results, and ask for more clarification.

We're not going to just write a whole test program just for you.

6. ## Yes i tried

i have tried with this:

Code:
sprintf(msg, "Teste %02.2d",100);
sprintf(msg, "Teste %02.2d",100000);
sprintf(msg, "Teste %02.2d",100000000);

sprintf(msg, "Teste %2.2d",100);
sprintf(msg, "Teste %2.2d",100000);
sprintf(msg, "Teste %2.2d",100000000);
And still the same result for both.

1 - And again, i dont want you to write a program for me, i just want to know whats the difference between 2 masks(o2.2 and 2.2).

2 - I looked at the reference before and i understood that the 0 is used for left padding... Buf even if i dont use the 0 i still got the padding of 0 on the .2 number...

i just want to know something like "ITS FOR PADDING" or "ITS FOR THIS OR THAT", dont a program write if you dont want to your "majesty" ^^

7. Originally Posted by RLeePlusPlus
i have tried with this:

Code:
sprintf(msg, "Teste %02.2d",100);
sprintf(msg, "Teste %02.2d",100000);
sprintf(msg, "Teste %02.2d",100000000);

sprintf(msg, "Teste %2.2d",100);
sprintf(msg, "Teste %2.2d",100000);
sprintf(msg, "Teste %2.2d",100000000);
And still the same result for both.

1 - And again, i dont want you to write a program for me, i just want to know whats the difference between 2 masks(o2.2 and 2.2).

2 - I looked at the reference before and i understood that the 0 is used for left padding... Buf even if i dont use the 0 i still got the padding of 0 on the .2 number...

i just want to know something like "ITS FOR PADDING" or "ITS FOR THIS OR THAT", dont a program write if you dont want to your "majesty" ^^
Ummm... why don't you try changing all those 2s to 8s and see what happens?

Really... rather than getting all ........ed off, do some real experimenting.

8. ## still got the same results

i still got the same results, with or without the '0' preceding the width... Just for information, i'm using VS2010 express

thank you

9. So, now you have your answer... It doesn't matter (in VS2010).

10. Originally Posted by RLeePlusPlus
i still got the same results, with or without the '0' preceding the width... Just for information, i'm using VS2010 express

thank you

Once you do that, it will be clear that you will see a difference using a single digit value, like 7.

11. ## Why it doesn't matter in VS 2010?

Why it doesn't matter in VS 2010? in GCC/GPP i have to put the 0?

12. Originally Posted by RLeePlusPlus
Why it doesn't matter in VS 2010? in GCC/GPP i have to put the 0?
Because that's the way the libraries are written.

Really... I'm no more telepathic than you are... I have no idea why programmer A decides one thing and programmer B decides another.
Just accept these things as they are, use them, and get on with it.

13. ## ok...

man, you really S U CK S... telepatic? Its not about to accept and use! Its about WHY IS DIFFERENT or IS REALLY DIFERENT? What a stupid reply... leave this for who want to discuss. You should be banished for answer questions like this.

14. Oh my... yet another short fuse who can't deal with reality.

Look sport... Some compilers and libraries do things differently... only the authors of those libraries know why and for the most part they're not talking. What do you want me to tell you? The only available answer is that we don't know why... we are thus left to work with what is before us.

You can talk about it till you're blue in the face... nothing is going to change that basic fact.

Now... get that foul temper of yours under control, or get lost.

15. Originally Posted by CommonTater
Because that's the way the libraries are written.

Really... I'm no more telepathic than you are... I have no idea why programmer A decides one thing and programmer B decides another.
Just accept these things as they are, use them, and get on with it.
Can you stop feeding conslusions of his own poor experimentation back at him as though they were answers? It irks me almost as much it must irk him.
He's stupidly listening to your interpretation of his results instead of actually reading the documentation, and is incorrectly concluding that Visual Studio is broken, which it is not.

RLeePlusPlus they do give different results, you're just not reading the documentation to see what values would make it give different results. I've already told you one answer and yes it will give a different result in Visual Studio.
Now stop wasting everyone's time and actually read the link posted. If you don't understand part of what it says then ask a specific question about that part.