Gethostname() function
Fermé
Emoragi
Messages postés
125
Date d'inscription
mercredi 2 juin 2010
Statut
Membre
Dernière intervention
19 juin 2016
-
Modifié par Whismeril le 7/07/2015 à 07:10
mamiemando Messages postés 33623 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 11 avril 2025 - 17 juil. 2015 à 12:37
mamiemando Messages postés 33623 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 11 avril 2025 - 17 juil. 2015 à 12:37
A voir également:
- Gethostname() function
- (Function(){css.removeclass(document.body,%20'profile_two_columns'); tab_controller.changepage("photos");})() - Forum Webmastering
- Unable to load function ft_thunk (kernel32.dll) ✓ - Forum Jeux vidéo
- Call to undefined function mysql_error() - Forum Programmation
- Excel decile function - Forum Excel
- Function ConcatForQuery ✓ - Forum Access
1 réponse
mamiemando
Messages postés
33623
Date d'inscription
jeudi 12 mai 2005
Statut
Modérateur
Dernière intervention
11 avril 2025
7 840
17 juil. 2015 à 12:37
17 juil. 2015 à 12:37
Bonjour,
Si tu regardes dans
Voici un code qui fonctionne chez moi :
Résultat :
Bonne chance
Si tu regardes dans
man gethostname(dans google, ou dans un terminal linux) tu verras que la variable
errno(et la fonction
strerror) te permettra sans doute de comprendre d'où vient ton problème.
Voici un code qui fonctionne chez moi :
#include <errno.h> #include <stdio.h> #include <string.h> #include <unistd.h> int main() { const size_t LEN = 100; char name[LEN]; if (gethostname(name, LEN) == -1) { fprintf(stderr, "%s\n", strerror(errno)); return 1; } printf("name = %s\n", name); return 0; }
Résultat :
(mando@aldur) (~) $ gcc main.c
(mando@aldur) (~) $ ./a.out
name = aldur
Bonne chance