c - wrong output on eclipse -


i open file called "elenco" in order write strings taken keyboard input, files create through eclipse empty, ideas why? before problem regularly wrote on file, output full of strange symbols.

ds_file = open("elenco",o_rdwr|o_creat, 0666); if (ds_file==-1) {     perror("errore nell'apertura del file"); } 

with take strings keyboard

printf("cognome >> ");                         scanf("%s", cognome);                         printf("nome >> ");                         scanf("%s", nome);                         printf("telefono >> ");                         scanf("%s", telefono); 

and write parameters in file list, using support struct called contacts

int aggiungi(contatto a, int df){ int sizewr;  lseek(df,0,2);  sizewr=write(df, a.cognome, sizeof(a.cognome)); if(sizewr==-1) return 0; sizewr=write(df, a.nome, sizeof(a.nome)); if(sizewr==-1) return 0; sizewr=write(df, a.telefono, sizeof(a.telefono)); if(sizewr==-1) return 0;  return 1; //contatto aggiunto correttamente 

}

any ideas solve problem? if need more specifications ask,the problem complex explain in few lines.

edit: explain shortly how application works: server manages file elenco (creating) interacting multiple clients take (from keyboard) name, lastname , phone number in order create phone book in elenco.

for communication between client , server use sockets.there others functions research , other stuff.

here whole code of application:

http://pastebin.com/tzeukd6c http://pastebin.com/hsdu9s1h


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -