none
Usage of format control %1!d! RRS feed

  • 问题

  • Hello everyone,

    Recently, I came across a kind of format control that I never saw before. 

    printf("Data recv failed (%1!d!)。\n\0", WSAGetLastError());

    What's the meaning of ‘!’?

    Thanks in advance!

    2015年10月9日 9:59

答案

  • Hi,

    Where did you see this format? What result will you get if you write like this?

    Could you please show the whole demo code here?

    I write a simple demo to test this format with printf, it will not print the variable we want.

    #include "stdafx.h"
    #include <iostream>
    
    using namespace std;
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	int d = 10;
    	printf("%1!d!",d);
    	getchar();
    	return 0;
    }
    
    

    The result is:

    So, in my opinion, this is incorrect format for printf. More about valid format for printf, you can refer to this link.

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    2015年10月12日 9:34