首页 \ 问答 \ C中的禁止内存位置(Off-limit memory locations in C)

C中的禁止内存位置(Off-limit memory locations in C)

这段代码是否有效C:

fputc(*("Checking 7 bytes before this string"-7), stdout);

C标准中有什么反对这样做的吗? 即在字符串文字之前读取几个字节。 那怎么样:(假设这些位置实际上存在于该过程中)

for (i=(char *)0x400000; i<(char *)0x400800; ++i) fputc(*i, stdout);

如果这些是有效的,C中是否有任何禁止存储位置?

谢谢。


Is this code valid C:

fputc(*("Checking 7 bytes before this string"-7), stdout);

Is there anything in the C standard against doing this? i.e reading a couple of bytes before a string literal. What about this: (assuming that these locations actually exist for the process)

for (i=(char *)0x400000; i<(char *)0x400800; ++i) fputc(*i, stdout);

If these are valid, are there any off-limit memory locations in C?

Thank you.


原文:https://stackoverflow.com/questions/9961732
更新时间:2023-11-29 14:11

最满意答案

这不是默认行为,但您可以通过使用脏逻辑来实现此目的。 在您的接收器/服务类[生成通知]中,只需检查所需应用程序的任何活动是否有效。 如果您的应用程序未处于活动状态而不是不生成通知。


It's not default behavior but you could achieve this by using a dirty logic. In your receiver/service class [who generates notification], just check any activity of your required application is active or not. If your application is not in active state than don't generate the notification.

相关问答

更多
  • 这不是默认行为,但您可以通过使用脏逻辑来实现此目的。 在您的接收器/服务类[生成通知]中,只需检查所需应用程序的任何活动是否有效。 如果您的应用程序未处于活动状态而不是不生成通知。 It's not default behavior but you could achieve this by using a dirty logic. In your receiver/service class [who generates notification], just check any activity of ...
  • 不确定您检查过的文档,但是在Nexus One下方的静音模式复选框中,它清楚地表明: Silence all sounds except media & alarms. 在你的例子中,你正在玩闹钟(不通知),所以它是正确的。 Not sure about the documentation you checked, but on Nexus One below Silent mode checkbox it clearly says: Silence all sounds except media & a ...
  • private void ahoo() { // TODO Auto-generated method stub Intent intent = new Intent("helpsettings.ListOfFilesCopied"); intent.putStringArrayListExtra("nameOfFilesCopied", arrayList); PendingIntent pi = PendingIntent.getActivity(this, 0, i ...
  • 对话框通知是: 对话框通常是一个小窗口,出现在当前活动的前面。 底层的Activity失去焦点,对话框接受所有的用户交互。 对话框通常用于与正在进行的应用程序直接相关的通知和短期活动。 (有关它的图形示例,请参阅下面的链接) 资料来源: http : //developer.android.com/guide/topics/ui/notifiers/index.html#Dialog A dialog notification is: A dialog is usually a small window t ...
  • 请参阅: 用户选择的时间 这是他们使用的通知服务: package com.blundell.tut.service; import android.R; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Intent; import andr ...
  • 由于没有人想出解决方案,我将回答我自己的问题。 似乎没有办法实现我想要的,至少在最新的Android版本中。 所以我最终做了以下丑陋的解决方法: 我现在通过RINGER_MODE_SILENT静音整个电话(来电和通知),但也通过BroadcastReceiver收听来电。 一旦检测到来电,RingerMode就会恢复到之前的状态。 这有效地实现了我想要实现的功能。 但是,我对这种解决方法非常不满意。 Since nobody came up with a solution, I'm going to ans ...
  • 既然你已经将主题改为android ......我可以帮忙! Kivy有一个姐妹项目, plyer ,提供独立于平台的方式,通过单个pythonic界面访问不同的apis。 Android实现了很多接口,包括通知,因此您可以直接使用plyer和/或查看代码以查看其工作原理。 碰巧我以前做了一个关于android东西的简短视频,你可以在这里找到。 这只是一个非常快速的介绍,但可能有所帮助。 Since you've changed your topic to android...I can help! Kiv ...
  • 通过以下方式修改代码: func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler handler: (UIBackgroundFetchResult) -> Void) { if let apsValue = userInfo["aps"] as? NSDictionary { i ...
  • 使用android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 。 请明智地使用它。 用户喜欢能够看到他们的通知,信号强度,电池电量等。 Use android:theme="@android:style/Theme.NoTitleBar.Fullscreen". Please use this judiciously. Users like being able to see their notifications, signal strength ...
  • 所以我终于找到了解决方案。 可以使用onWindowFocusChanged()覆盖。 即使在打开通知中心的情况下,当app失去焦点时也会调用此方法。 So I finally found the solution. It is ok to use onWindowFocusChanged() override. this is called when app lost focus even in that case of opening notification center.

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)