<pre> #include <stdio.h> #include <fcntl.h> #include <errno.h> int main(int argc, char *argv[]) { int i,n,f; char buffer[256]; if (argc!=3) { printf("Uso: %s <intero positivo> <nomefile>\n",argv[0]); exit(15); } sscanf(argv[1],"%d",&n); f=open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 00644); if (f==-1) { printf("Non riesco ad aprire il file!\n"); exit(15); } for (i=1; i<=10; i++) { sprintf(buffer,"%2d x %2d = %3d\n",n,i,i*n); if (write(f,buffer,strlen(buffer))==-1) printf("Non riesco a scrivere! Errore: %d\n",errno); } close(f); } </pre> -- Users.AntonioValletta - 12 Nov 2001 <br>
This topic: Sistemioperativi1
>
Tabelline
Topic revision: r3 - 2001-11-26 - AntonioValletta
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback