- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有这样一段代码:
#include <stdio.h>
int main(void)
{
char *date = "Sunday";
//int *number = 7;
printf("Today is %s, the 7 days of this week", date);
}
它按预期工作并打印
$ ./a.out
Today is Sunday, the 7 days of this week
尽管如此,当我取消评论时
#include <stdio.h>
int main(void)
{
char *date = "Sunday";
int *number = 7;
printf("Today is %s, the %d days of this week", date, *number);
}
报错:
$ cc draft.c
draft.c:5:10: warning: incompatible integer to pointer conversion initializing 'int *' with an expression of type
'int' [-Wint-conversion]
int *number = 7;
^ ~
1 warning generated.
我的代码有什么问题?
最佳答案
应该是
int number = 7;
printf("Today is %s, the %d days of this week", date, number);
代替
int *number = 7;
printf("Today is %s, the %d days of this week", date, *number);
在第一个片段中,一个整型变量被初始化为 7 并且它的值被打印出来。在第二个片段中,一个指针用地址 7 初始化,然后打印内存地址 7 处的整数值。
关于c - *日期 = "Sunday"; vs int *数字= 7;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52913360/
我在计算员工一个月的缺勤率时遇到问题。在我的查询中,它仍然计算本月“星期日”的那一天,这不应该计算在内。 这是使用的示例数据库: emp0003 表的 尼克 姓名 01190301 苏珊 dvc000
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
这个问题已经有答案了: Get the number of weeks between two Dates. (19 个回答) 已关闭 8 年前。 看看你能不能帮我。我想获取两个日期 d1 和 d2
我有一个 9 月 2 日星期二的 GregorianCalendar 实例。 valñue 以毫秒为单位进行检查,没有问题。我想要下一个星期日(7 日)23:59:59 的另一个日历。所以: Greg
我正在尝试获取下一个“该月的第二个星期日”的时间戳,无论是当月还是下个月。 要求是只使用一次 strtotime 函数,并且没有第二个参数,仅此而已(这些约束来自遗留代码)。 基本上,获取它的 PHP
我正在尝试获取下一个“该月的第二个星期日”的时间戳,无论是当月还是下个月。 要求是只使用一次 strtotime 函数,并且没有第二个参数,仅此而已(这些约束来自遗留代码)。 基本上,获取它的 PHP
我正在使用Java的Calendar API来计算每个月第一天的星期日总数。以下代码为我提供了日期格式(年/月/日)的指定开始日期和结束日期 1 天的额外时间。 1900/01/01 至 1910/0
我需要周日以红色突出显示。 我知道有一个名为ui-datepicker-week-end的类。 我的问题是,其他类(ui-widget-content 和 ui-state-default)覆盖了 u
我有一个小表格,我想将我的日历设置为自动选择即将到来的星期日,我该如何实现?我有一种感觉,我必须做一些加载但不确定是什么。 谢谢 最佳答案 你去... 使用此方法,您可以将日期设置为您决定的一周中的任
我知道有一些与此类似的问题,但我就是找不到我的代码有什么问题。 基本上我想要的是如果今天不是星期天,currentDate 设置为最后一个星期日。如果今天是星期日,我将 currentDate 设置为
2013 年 7 月 8 日编辑:Apple 拥有一组出色的 WWDC 视频,这些视频真正帮助我理解了 Objective-C 中的各种日期和时间类,以及如何使用它们正确地执行时间计算/操作。 “常见
我有一份报纸目录: 20140914_foo.pdf 20140915_foo.pdf 20140916_foo.pdf 我想将它们重命名为 2014-09-14 Sunday.pdf 2014-09
为了让我的 child 快乐,我一直在实现 Yellow Car Game PHP 语言用于长途汽车旅行。其中一个人会在我的手机上看到黄色汽车时添加这些汽车。计数器应该增加他们的每个分数,每个周日晚上
我无法找到我想要的特定日期格式的解决方案,例如2019 年 10 月 31 日星期日。我还需要日期的偏移值。 我能得到的最接近时间是2019 年 10 月 31 日星期日。我需要能够用用户输入的数字来
我有这样一段代码: #include int main(void) { char *date = "Sunday"; //int *number = 7; printf("T
为什么它会返回 rainyday[1] = Sunday 而不是星期五?并在其他地方返回 main() 中定义的所有值 Namespace ConsoleApp_toTestYourself
在随机字符下,Sunday算法比bm算法更快。 那么,为什么在文本编辑器的查找功能中选择“BM算法”而不是“星期日算法”呢? 最佳答案 对于为什么要选择一个而不是另一个,没有简单的答案。 “BM”是指
NSString *strDay = [dic objectForKey:@"day"]; NSString *uppercaseString = [strDay uppercaseString];
有没有办法把这段代码总结成1-2行? 我的目标是返回,例如,我有一个 DayOfWeek 是星期一,我想得到之后的一天(星期二)或之后的 n 天。 switch (_RESETDAY
我正在编写一个抓取网站优惠的抓取工具,这些优惠有结束日期。一个这样的网站提供每周日到期的优惠。我已经阅读了 golang 时间文档,但仍然不明白如何完成我在 PHP 中发现的等效性并且非常简单。 $e
我是一名优秀的程序员,十分优秀!