我正在尝试使用#include <stdio.h>
#include <stdlib.h>
void reserve_space(char **c, int *capacity);
void print_signs(const char *signs, int max_size);
int cmp(void const *lhs, void const *rhs);
// allocates factor 2 of the current capacity
void reserve_space(char **c, int *capacity) {
if (*capacity == 0) { // allocate the first time
*capacity = 1;
*c = malloc(sizeof(char) * ((*capacity)));
} else {
*capacity *= 2; // double the new capacity
*c = realloc(*c, sizeof(char) * (*capacity));
}
}
void print_signs(const char *signs, int sz) {
int i = 0;
for (i = 0; i < sz; ++i) {
printf("%i %c\n", signs[i], signs[i]);
}
printf("\n");
}
int cmp(void const *lhs, void const *rhs) {
unsigned char left = *(const unsigned char *)lhs;
unsigned char right = *(const unsigned char *)rhs;
if (left < right) return -1;
if (left > right) return 1;
return 0; /* left == right */
}
int main() {
int sz = 0; // space currently "filled" with signs
int capacity = 0; // allocated space
char *signs = NULL;
int ch;
while ((ch = getc(stdin)) != EOF) {
int pos = 0;
for (pos = 0; pos < sz; ++pos) {
if (signs[pos] == ch)
break;
}
if (pos < sz)
continue; // character is already in the array
if (sz == capacity)
reserve_space(&signs, &capacity);
signs[sz] = ch; // append the sign in the array
sz++;
// '\0' terminator is not needed as array is not used as a string
}
qsort(signs, sz, sizeof(char), cmp);
print_signs(signs, sz);
free(signs);
getchar();
return 0;
}
从本地文件系统安装python包,如question中所述。
我在上述问题的接受答案中建议使用pip
。
pip2pi
下载的软件包
dmanna@ubuntu:~$ mkdir -p pyt/pkg
dmanna@ubuntu:~$ pip2tgz pyt/pkg/ patroni[zookeeper]
然后当我尝试从上面的本地目录安装所需的包时。它给了我以下错误
dmanna@ubuntu:~$ ls /home/dmanna/pyt/pkg/
cdiff-1.0.tar.gz
certifi-2018.4.16-py2.py3-none-any.whl
chardet-3.0.4-py2.py3-none-any.whl
click-6.7-py2.py3-none-any.whl
idna-2.7-py2.py3-none-any.whl
kazoo-2.5.0-py2.py3-none-any.whl
patroni-1.4.4.tar.gz
prettytable-0.7.2.tar.bz2
psutil-5.4.6.tar.gz
psycopg2-2.7.4.tar.gz
python_dateutil-2.7.3-py2.py3-none-any.whl
pytz-2018.4-py2.py3-none-any.whl
PyYAML-3.12.tar.gz
requests-2.19.1-py2.py3-none-any.whl
six-1.11.0-py2.py3-none-any.whl
tzlocal-1.5.1.tar.gz
urllib3-1.23-py2.py3-none-any.whl
有人能让我知道我做错了吗?
Python - 2.7.6 PIP - 1.5.4 Ubuntu 14.04
答案 0 :(得分:0)
--find-links=pyt/pkg
在目录中查找链接,而不是patroni-1.4.4.tar.gz
存档。