Bonjour,
J'aimerai savoir si il est possible, dans un programme en C, imprimer via cups ?
Si oui, comment ? (Ce serait pour un programme sur Macos 10.4).
Merci
Bonjour,
J'aimerai savoir si il est possible, dans un programme en C, imprimer via cups ?
Si oui, comment ? (Ce serait pour un programme sur Macos 10.4).
Merci
Je dirais quelque chose comme:
où mon_imprimante est une des imprimantes listées par la commande:
Code : Sélectionner tout - Visualiser dans une fenêtre à part system("lpr -P mon_imprimante mon_fichier");
Thierry
Code : Sélectionner tout - Visualiser dans une fenêtre à part lpstat -p -d
"The most important thing in the kitchen is the waste paper basket and it needs to be centrally located.", Donald Knuth
"If the only tool you have is a hammer, every problem looks like a nail.", probably Abraham Maslow
FAQ-Python FAQ-C FAQ-C++
+
Salut,
Je reviens à la charge avec mon problème d'impression.
voici mon code
Evidement nom de fichier ne va pas... logique, alors j'avais essayé avec le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 void printing(void) { char nomfichier[8]; //int jobid; system("ls -l"); fflush(stdin); printf("Quel fichier imprimer ? "); scanf("%s",&nomfichier); /*if (jobid == 0) puts(ippErrorString(cupsLastError())); jobid = cupsPrintFile("Stylus_D88", nomfichier, nomfichier, 0, NULL);*/ system("lpr -P Stylus_D88 nomfichier"); return; }
Bien sur gcc me renvoie une erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 system("lpr -P Stylus_D88 %s", nom fichier);
.
Code : Sélectionner tout - Visualiser dans une fenêtre à part too many arguments to function 'system'.
Je me doute qu'il doit bien y avoir une solution mais là, je cale... si quelqu'un pouvait me mettre sur la voie....
Bonjour,
Il suffit de formatter la chaine de caractères avant de l'utiliser dans la fonction system :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 char cmd[256]; sprintf(cmd, "lpr -P Stylus_D88 %s", nom fichier); system(cmd);
mais oui évidement...![]()
pourquoi n'y ais-je pas pensé... merci
La fonction system() ne s'utilise pas comme printf(). Essaie de préparer ta chaîne avec strncat() ou sprintf() ou encore snprintf() et de la passer ensuite à system().
Thierry
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #include <stdio.h> #include <string.h> /* -tc- ajouter les fichiers: * - http://thierry-chappuis.ftp-developpez.com/codes/mlib/fclean.h * - http://thierry-chappuis.ftp-developpez.com/codes/mlib/fclean.c * au projet */ #include "fclean.h" void printing(void) { char nomfichier[16] = ""; char tampon[128] = "lpr -P Stylus_D88 "; printf("Quel fichier imprimer ? "); fflush(stdout); fgets(nomfichier, sizeof nomfichier, stdin); fclean(nomfichier, stdin); strncat(tampon, nomfichier, sizeof tampon - strlen(tampon) - 1); system(tampon); return; }
"The most important thing in the kitchen is the waste paper basket and it needs to be centrally located.", Donald Knuth
"If the only tool you have is a hammer, every problem looks like a nail.", probably Abraham Maslow
FAQ-Python FAQ-C FAQ-C++
+
Partager