#include <stdio.h>
#define N 10
char str2[N]={"Hello"};
int main(){
printf("sizeof(str2): %d bytes\n", sizeof(str2));
printf("sizeof(&str2): %d bytes\n", sizeof(&str2));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
sizeof(str2): 10 bytes
sizeof(&str2): 4 bytes
Run Code Online (Sandbox Code Playgroud)
我知道str2单独是数组中第一个元素的地址str2.并且当str2它的参数何时sizeof返回整个数组str2的大小.
另外,&str2也是arr中第一个元素的地址,str2但是来自不同的类型(char (*)[N]==指向数组的指针).但是&str2当它是一个论证时,它是如何表现的sizeof?
我有一个适合webapp(主屏幕)高度的问题.我使用以下元标记:
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
Run Code Online (Sandbox Code Playgroud)
我的问题是,屏幕顶部和底部有黑条.首先我想,由于屏幕较高,这是iPhone 5的一个错误.但是今天我看到了一个适合iphone5屏幕的webapp(apps.ft.com/).
任何想法,我做错了什么?
这里是我完全相关的元标记
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" href="img/icons/ios_icon_52.png">
<link rel="apple-touch-icon" href="img/icons/ios_icon_52.png">
<link rel="apple-touch-icon" sizes="72x72" href="img/icons/ios_icon_72.png">
<link rel="apple-touch-icon" sizes="114x114" href="img/icons/ios_icon_114.png">
Run Code Online (Sandbox Code Playgroud)
编辑:经过一个小时的搜索,我找到了解决方案如何强制浏览器适应全高度.当我定义一个启动图像(apple-touch-startup-image)时,我的iphone只适合高度.这是我的代码:
<!-- iPhone 4 (Retina) -->
<link href="img/icons/apple-touch-startup-image-640x920.png"
media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2)"
rel="apple-touch-startup-image">
<!-- iPhone 5 -->
<link href="img/icons/apple-touch-startup-image-640x1096.png"
media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)"
rel="apple-touch-startup-image">
Run Code Online (Sandbox Code Playgroud) 我有一个枚举
public enum Days {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY
Run Code Online (Sandbox Code Playgroud)
}
我想创建一个可以获取类型为days的值的类.所以我使用了Java Generics
public class State<T extend Days>
Run Code Online (Sandbox Code Playgroud)
但是有一个错误
The type parameter T should not be bounded by the final type Days.
Final types cannot be further extended
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
我很好奇是否有类似于c ++中的Java哈希集的东西.即具有快速外观的数据结构,因为我只会在其上运行.contains(e).同样,如果您可以启发我如何对您提出的任何数据结构执行.contains(),我将非常感激.哦,请不要发布只是看看c ++文档,因为我已经这样做了,发现它们很麻烦.
我实际上正在阅读有关微服务架构的文章,但似乎他们正在以最简单的方式处理事情,而不是更深入地解释.
为了向您解释我的问题,我将向您展示我的实际小建筑:

所以,这就是我想要使用的.在技术上做任何事之前,我需要更多的理论信息.
我的域名的描述
我有一些基于移动和浏览器的客户,能够在应用程序上连接自己,获取用户信息并能够查询有关他们购买的产品的账单信息.
在单片应用程序中,我将使用这种架构: - 具有Mobile/Angular-Ember的表示层 - 带有NGINX的REST API的业务层 - 带有标准MySQL数据库的DAL - 可扩展性仅适用于X轴
在这种情况下,我想使用微服务架构,因为它是"域可扩展的"并且非常灵活(当然要学习更多关于它的内容).
在架构上,在每个服务中,都有相关API公开的唯一HTTP URL.
问题
a /在(1)flux中,"mobile"在http://myDomain.or/auth上发送http请求.
在我看来,APIGateway能够要求标准的服务注册表(Eureka,ZooKeeper或其他东西)能够找到AuthSrv是否可访问并且可以检索他的网络地址.然后ApiGateway可以请求AuthSrv并响应服务器
这是一个让它运作的好方法吗?处理X机器访问数据时是否存在延迟问题?
b / flux(2)咨询服务注册表.服务注册表如何理解/ auth上的每个请求,甚至在/ auth/other之类的子URL上(如果它被暴露)与此地址ip:port上的此服务相关?
c / flux(3)显示服务注册表具有可用的AuthSrv.(3之二)显示另一个:没有AuthSrv可用.在一个小应用程序中,我们可以承认我们失去了一段时间的可用性,但在一个大型系统中,有数百个服务链接在一起,我们如何处理服务缺陷?
d /在另一篇文章中,我询问如何存储结算信息,因为它与用户,其他服务和另一个数据库相关.
在标准架构中,我会:
{
billingInformations:{...},
billingUser:ObjectId("userId")
}
Run Code Online (Sandbox Code Playgroud)
在微服务架构中,有人建议使用:
{
billingInformations:{...},
billingUser:"/user/12365" // URL corresponding the the user Resource in the other service
}
Run Code Online (Sandbox Code Playgroud)
这是处理"服务数据共享"而不是耦合服务的最佳方式吗?
e /在这种特定情况下,我应该何时更喜欢使用AMQP协议而不是HTTP协议?
谢谢你提前
我从未遇到像Python(隐式)或PHP(显式&)那样的引用问题.在PHP中,您可以编写$p = &$myvar;并$p作为参考指向$myVar.
所以我知道在C++中你可以这样做:
void setToSomething( int& var )
{
var = 123;
}
int myInt;
setToSomething( myInt );
Run Code Online (Sandbox Code Playgroud)
不是指C++中"x的内存地址"?如果var只是地址myInt而不是指针,我该怎么办?
void setToSomething( int* var )
{
*var = 123;
}
int myInt;
int* myIntPtr = &myInt;
setToSomething( myIntPtr );
Run Code Online (Sandbox Code Playgroud)
我完全不理解*和&之间在C++中的区别.他们告诉你并且习惯于获取变量的地址,但是为什么它会帮助你处理函数等.就像在第一个例子中一样?
假设我有一个std :: vector,我通过某种方式获得了第n个元素的地址.给定我的std :: vector的基地址,是否有一种简单的方法(比迭代迭代更快)来获得元素出现的索引?让我们假设我确定元素在向量中.
只要我的服务正常工作,我就会在状态栏中保留FLAG_ONGOING_EVENT通知,并且每秒更新一次.
在Android 8之后,我添加了Notification Channel,并且8和8+设备都运行良好,但是8个以上的设备每秒都在向我的logcat填充以下警告,这非常烦人:
04-10 20:36:34.040 13838-13838/xxx.xxxx.xxxx W/Notification: Use of stream types is deprecated for operations other than volume control
See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
Run Code Online (Sandbox Code Playgroud)
我很确定我没有声音通道或通知本身.
以下是我创建通知渠道的方法:
channel = new NotificationChannel(CHANNEL_ONGOING_ID,
getString(R.string.channel_ongoing_name),
NotificationManager.IMPORTANCE_LOW);
channel.setDescription(getString(R.string.channel_ongoing_desc));
mNotificationManager.createNotificationChannel(channel);
Run Code Online (Sandbox Code Playgroud)
我的通知:
RemoteViews view = new RemoteViews(getPackageName(),
R.layout.notification_ongoing);
view.setImageViewResource(R.id.notification_button,
mState == STATE_ONGOING ? R.drawable.ic_pause : R.drawable.ic_start);
view.setTextViewText(R.id.notification_text, Utils.getReadableTime(mMilliseconds));
view.setOnClickPendingIntent(R.id.notification_button,
PendingIntent.getBroadcast(mContext, 1, new Intent(INTENT_NOTIFICATION_TOGGLE),
PendingIntent.FLAG_UPDATE_CURRENT));
NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext,
CHANNEL_ONGOING_ID); …Run Code Online (Sandbox Code Playgroud) 我已经*.tfrecord从youtube-8m 项目下载了一些数据。您可以使用以下命令下载一小部分数据:
curl data.yt8m.org/download.py | shard=1,100 partition=2/video/train mirror=us python
我正在尝试了解如何使用新的 tf.data API。我想熟悉人们遍历数据集的典型方式。我一直在使用 TF 网站上的指南和这张幻灯片:Derek Murray 的幻灯片
这是我定义数据集的方式:
# Use interleave() and prefetch() to read many files concurrently.
files = tf.data.Dataset.list_files("./youtube_vids/*.tfrecord")
dataset = files.interleave(lambda x: tf.data.TFRecordDataset(x).prefetch(100),
cycle_length=8)
# Use num_parallel_calls to parallelize map().
dataset = dataset.map(lambda record: tf.parse_single_example(record, feature_map),
num_parallel_calls=2) #
# put in x,y output form
dataset = dataset.map(lambda x: (x['mean_rgb'], x['id']))
# shuffle
dataset = dataset.shuffle(10000)
#one epoch
dataset = dataset.repeat(1)
dataset = dataset.batch(200) …Run Code Online (Sandbox Code Playgroud) 我有一个基本的问题,char*我不明白
char* aString = "Hello Stackoverflow";
Run Code Online (Sandbox Code Playgroud)
指针指向字符链的第一个字符.
cout << *aString; // H
Run Code Online (Sandbox Code Playgroud)
但为什么整个字符串都保存在指针中?
cout << aString //Hello Stackoverflow
Run Code Online (Sandbox Code Playgroud)
我希望有一个地址,不是指针中保存的地址吗?"Hello Stackoverflow"的地址在哪里?
任何帮助非常感谢