什么是printf的签名? [英] What is the signature of printf?

查看:115
本文介绍了什么是printf的签名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

近日在接受采访时有人问我什么的printf的签名。
我真的不能得到正确的答案。会有人能够阐明这一些轻?


解决方案

  INT的printf(为const char *格式,...);

他们可能会问这个,看看你熟悉的可选参数语法...。这使您可以传递变量将在格式字符串填写一个不确定的列表。

例如,相同的方法可用于打印这样的事情:

 的printf(这是一个字符串:%S,myString的);
的printf(这是一个字符串:%s和一个int数:%d,MyString的,敏);

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?

解决方案

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

They were probably asking this to see if you were familiar with the optional parameter syntax "...". This allows you to pass an indeterminate list of variables that will fill in the format string.

For example, the same method can be used to print things like this:

printf("This is a string: %s", myString);
printf("This is a string: %s and an int: %d", myString, myInt);

这篇关于什么是printf的签名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆