我在字典中有一个单词列表,其值为=关键字的重复,但我只想要一个不同单词的列表,所以我想计算关键字的数量.有没有办法计算关键字的数量,还是有另一种方法我应该寻找不同的单词?
我有一个我创建的库,
mylib.c:
#include <mylib.h>
int
testlib() {
printf("Hello world\n");
return (0);
}
Run Code Online (Sandbox Code Playgroud)
mylib.h:
#include <stdio.h>
extern int testlib();
Run Code Online (Sandbox Code Playgroud)
在我的程序中,我试图调用这个库函数:
myprogram.c:
#include <mylib.h>
int
main (int argc, char *argv[]) {
testlib();
return (0);
}
Run Code Online (Sandbox Code Playgroud)
当我尝试编译该程序时,我收到以下错误:
In file included from myprogram.c:1 mylib.h:2 warning: function declaration isn't a prototype
我正在使用: gcc (GCC) 3.4.5 20051201 (Red Hat 3.4.5-2)
我的问题是,声明函数原型的正确方法是什么?
我的OCD使我在编写case语句时添加"break",即使它们不会被执行.请考虑以下代码示例:
switch(option) {
case 1:
a = 1;
b = 7;
break;
case 2:
a = 2;
b = 4;
return (-1);
break;
default:
a = -1;
break;
}
Run Code Online (Sandbox Code Playgroud)
我的两个问题是:
对于"案例2:",我真的不需要休息,但是无论如何将它放在那里是一个好主意吗?对于"默认:".这纯粹是强迫症,还是有任何真正的理由在这里休息?
套接字函数调用C可以返回0或1作为套接字描述符的值吗?
int socket(int domain, int type, int protocol);
Run Code Online (Sandbox Code Playgroud)
根据我的手册页:
RETURN VALUE
-1 is returned if an error occurs; otherwise the return value is a
descriptor referencing the socket.
Run Code Online (Sandbox Code Playgroud)
它似乎可以,或者至少手册页没有提到任何保留值.是否在其他地方写入了有效套接字描述符需要为2或更大?
我专门在linux 2.4.22内核上运行,但我很想知道任何基于unix的socket实现.
我有一个在裸机上使用 kubeadm 的 1.15.1 kubenetes 集群,并且刚刚部署了 metrics-server,如文档中所示:
git clone https://github.com/kubernetes-incubator/metrics-server.git
kubectl create -f metrics-server/deploy/1.8+/
Run Code Online (Sandbox Code Playgroud)
一段时间后,我尝试kubectl top node并得到以下回应:
错误:指标尚不可用
此外,当我尝试时,kubectl top pods我得到:
W0721 20:01:31.786615 21232 top_pod.go:266] 指标不适用于 pod 默认/pod-deployment-57b99df6b4-khh84,年龄:27h31m59.78660593s 错误:指标默认值/pod-deployment-57b99df6b4-khh84,不可用指标/pod-deployment-57b99df6b4-khh84s年龄:27h31m59.78660593s
我检查了度量服务器的 pod 和服务,它们都运行良好。我应该在哪里尝试查看问题?
我有这个简单的perl守护进程:
#!/usr/bin/perl
use strict;
use warnings;
use Proc::Daemon;
Proc::Daemon::Init;
my $continue = 1;
$SIG{TERM} = sub { $continue = 0 };
$SIG{USR1} = sub { do_process(1) };
# basic daemon
boxesd_log("started boxesd");
while ($continue) {
do_process(0);
sleep(30);
}
boxesd_log("finished boxesd");
exit(0);
# required subroutines
sub do_process {
my ($notified) = @_;
boxesd_log("doing it $notified");
}
Run Code Online (Sandbox Code Playgroud)
但有些事情是行不通的.
守护程序启动时,它会每30秒记录一次,而不会发出预期的通知:
Sat Oct 30 21:05:47 2010 doing it 0 Sat Oct 30 21:06:17 2010 doing it 0 Sat Oct 30 21:06:47 2010 doing it …
c ×3
coding-style ×1
count ×1
daemon ×1
dictionary ×1
gcc ×1
keyword ×1
kubeadm ×1
kubernetes ×1
linux ×1
monitoring ×1
perl ×1
python ×1
signals ×1
sockets ×1
unix ×1