Так?
но со 2 я не могу понять
абсолютная адресация по типу: MOV ЕAX, [0xFF00];
$ ssh -p 2222 -v 127.0.0.1 "cd / ; ls -la"
OpenSSH_6.7p1 Debian-5+deb8u3, OpenSSL 1.0.1t 3 May 2016
debug1: Reading configuration data /home/jcmvbkbc/.ssh/config
debug1: /home/jcmvbkbc/.ssh/config line 36: Applying options for 127.0.0.1
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2222.
debug1: Connection established.
debug1: identity file /home/jcmvbkbc/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jcmvbkbc/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jcmvbkbc/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jcmvbkbc/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jcmvbkbc/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jcmvbkbc/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jcmvbkbc/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jcmvbkbc/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Debian-5+deb8u3
debug1: Remote protocol version 2.0, remote software version dropbear_2014.65
debug1: no match: dropbear_2014.65
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: RSA e3:32:41:14:0f:fa:0b:0e:c7:6d:18:e8:12:a6:b5:28
Password authentication is disabled to avoid man-in-the-middle attacks.
Keyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/jcmvbkbc/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: Authentication succeeded (publickey).
Authenticated to 127.0.0.1 ([127.0.0.1]:2222).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = C.UTF-8
debug1: Sending command: cd / ; ls -la
total 172
drwxr-xr-x 26 root root 4096 Sep 29 2014 .
drwxr-xr-x 26 root root 4096 Sep 29 2014 ..
drwxr-xr-x. 2 root root 4096 Sep 14 11:18 bin
drwxr-xr-x. 3 root root 4096 Oct 1 01:11 boot
drwxr-xr-x 3 root root 4096 Nov 24 2015 cad
drwxr-xr-x 20 root root 3720 Nov 14 09:26 dev
drwxr-xr-x. 151 root root 12288 Nov 14 10:54 etc
drwxr-xr-x. 11 root root 4096 Aug 26 2016 home
lrwxrwxrwx. 1 root root 31 Nov 9 2015 initrd.img -> /boot/initrd.img-3.16.0-4-amd64
drwxr-xr-x. 18 root root 4096 Jun 24 19:19 lib
drwxr-xr-x 2 root root 4096 Jun 24 19:19 lib32
drwxr-xr-x. 2 root root 4096 Jun 24 19:19 lib64
drwxr-xr-x 2 root root 4096 Jun 24 19:19 libx32
drwx------ 2 root root 16384 Nov 22 2015 lost+found
drwxr-xr-x. 4 root root 4096 Jan 9 2016 media
drwxr-xr-x. 2 root root 4096 Nov 9 2015 mnt
drwxr-xr-x. 9 root root 4096 Jul 7 10:10 opt
dr-xr-xr-x 526 root root 0 Sep 8 22:40 proc
drwx------. 14 root root 4096 Nov 14 10:56 root
drwxr-xr-x 36 root root 1180 Nov 14 10:57 run
drwxr-xr-x. 2 root root 12288 Oct 17 02:12 sbin
drwxr-xr-x. 3 root root 4096 Aug 26 2016 srv
dr-xr-xr-x 13 root root 0 Nov 14 10:58 sys
drwxrwxr-x. 15 jcmvbkbc jcmvbkbc 4096 Jul 26 22:59 tftpboot
drwxrwxrwt 47 root root 57344 Nov 14 10:55 tmp
drwxr-xr-x. 17 root root 4096 Jan 31 2017 usr
drwxr-xr-x. 11 root root 4096 Sep 29 2014 var
lrwxrwxrwx. 1 root root 27 Nov 9 2015 vmlinuz -> boot/vmlinuz-3.16.0-4-amd64
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3296, received 3456 bytes, in 0.0 seconds
Bytes per second: sent 391117.1, received 410103.4
debug1: Exit status 0
Хорошо, у меня всего 140к слов в словаре, а если у меня, например, на 2 гигабайта словарь? Тоже самое?
Я думал, что когда мы объявляем массив указателей, то он заполнится мусорными значениями, и в таком случае мой список не будет иметь конца.
Получается, что если мы объявляем массив как глобальную переменную - то он всегда автоматически инициализируется нулями?
Кстати при таком варианте, компилятор выдает следующую ошибку:
typedef struct node
{
char word1[SIZE];
struct node *next;
} node;
node * new = malloc (sizeof (node));
//новый элемент структуры в поле next получает адрес текущей головы списка
new->next=hashtable[k];
//копируем в информационное поле нашей структуры считанное слово
new->word1 = strdup(word);
//делаем головой списка наш новый элемент
hashtable[k] = new;
правильно я всё понял?
Если я все правильно понял, то в данном варианте, все таки стоит инициализировать массив указателей как NULL...
...и делать проверку вставлялся ли ранее элемент в список или нет?
node *hashtable[26];
, тогда всё могло бы быть примерно так://максимальная длина слова в словаре
#define SIZE 45
int hash_function (char* key);
//определяем структуру
typedef struct node
{
char *word1;
struct node *next;
} node;
//создаем хэш-таблицу, в которой будут хранится списки
node *hashtable[26];
int main()
{
char *text = "small";
FILE *fp = fopen(text, "r");
if (fp == NULL)
{
printf("Could not open %s.\n", text);
return 1;
}
char word[SIZE];
while(!feof(fp))
{
//считываем слово из словаря
fscanf(fp,"%s",word);
//определяем его место в массиве
int k=hash_function(word);
//добавляем слово
node * new = malloc (sizeof (node));
new->next=hashtable[k];
strcpy(new->word1, word);
hashtable[k] = new;
}
fclose(fp);
return 0;
}
int hash_function (char* key)
{
int hash = tolower (key [0]) - 'a';
return hash;
}
#if (n < 3)
n не является определённым символом препроцессора, поэтому препроцессор заменяет его на 0. 0 < 3 -- истина, блок кода компилируется.