format-specifiers

    -1热度

    3回答

    当我使用printf()函数,然后scanf()我遇到了麻烦。 我在代码的下面写道,eclipse编译器说没有错误也没有警告,但是当我编译它时,它显示:insert array dimension insert array elements。它不会让我插入任何东西,程序结束。 我也尝试添加fflush(stdout)但没有任何更改。 我能做什么? int main(void) { int

    0热度

    4回答

    由于目前我还不明白的原因,尽管拥有完成任务所需的所有内容,但此代码仍无法编译。 #include <stdio.h> /* printf */ #include <math.h> double resistance; double voltage; double current; double wattage; int main() { printf("type i

    -1热度

    1回答

    函数converterm(met, bri);被调用时没有返回正确的值。代码仍然不完整,但适用于某些选项。只需输入数值,并在每次询问选择哪个选项时,选择选项1并查看结果。 在这一行conm.m = conb.ft/3.2808;它不返回期望的值。 //METRIC_BRITISH - BUILD 1.0 #include<stdio.h> #include<stdlib.h> #inclu

    1热度

    2回答

    我在AC实例涉及到的“printf”指令一个问题: printf("Percentage character: %%",10); 输出是正确的:百分比字符:% 这是为什么格式-specifier(%%)?那边那10块是什么?为什么编译器说printf的参数太多? 我试图显示以另一种方式的百分比字符: printf("Percentage character: %c",putch(37));

    -2热度

    1回答

    我正在从here获知C中与时间相关的函数。他们证明了使用以下示例的strftime()函数: #include <stdio.h> #include <time.h> #define LEN 150 int main() { char buf[LEN]; time_t curtime; struct tm *loc_time; //Getting

    3热度

    2回答

    我目前正在开发一个简单的C应用程序。这需要一个单一的文件作为命令行参数,它的格式如下: 1,2,3 4,5,6 7,8,9 etc. 然而,无论出于何种原因,fscanf从未扫描数字!这里有一个例子: #include <stdio.h> int main(int argc, char **argv) { FILE *file = fopen(*argv, "r");

    11热度

    1回答

    假设我忘记关闭扫描集的右方括号]。那么会发生什么?它是否调用未定义的行为? 例子: char str[] = "Hello! One Two Three"; char s1[50] = {0}, s2[50] = {0}; sscanf(str, "%s %[^h", s1, s2); /* UB? */ printf("s1='%s' s2='%s'\n", s1, s2); 编译时我

    3热度

    1回答

    我最近升级到Xcode7,并且在使用%p格式说明符时我的输出发生了更改。当我运行的代码(如下): IOLog("%s[%p]::%s()\n", getName(), this, \_\_FUNCTION\_\_); 我得到: com_MyCompany_MyDriver [< PTR>] ::的init() 使用Xcode6我得到: com_MyCompany_MyDriver [0xfff

    2热度

    1回答

    哪个是scanf(),%[-A-B234abc]或%[A-B234abc-]正确的扫描集格式说明符语法?我找不到StackOverflow上的答案,以下两个链接给矛盾的答案: cplusplusreference: 破折号( - ),是不是第一个字符可能会产生一些库实现非便携的行为。 beez: 要匹配一个连字符,使其成为最后一个字符集:%[A-C-]。

    5热度

    1回答

    我一直使用的格式说明,但今天%d或%@但他们一般喜欢在一个教程中,我看到了这些%[email protected]%2$d,不明白他们代表什么。 这是一个计算器示例,因此他们在本声明中使用它们:stack = [NSString stringWithFormat:@"%[email protected]%2$d",stack,number];