What is the signature of printf?

前端 未结 3 359
伪装坚强ぢ
伪装坚强ぢ 2020-12-03 15:46

Recently in an interview I was asked about what the signature of printf is. I really couldn\'t get a right answer. Would someone be able to shed some light on this?

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 16:10

    printf is a variadic function with the following signature:

    int printf(const char *format, ...);
    

    this means that it has one required string parameter, followed by 0 or more parameters (which can be of various types). Finally, it returns an int which represents how many characters are in the result.

    The number and type of the optional parameters is determined by the contents of the format string.

提交回复
热议问题