xsatellitex
01-01-2008, 22:39
Scusate sapete dirmi perche questo programma mi visualizza un output sbagliato?sotto ho riportato l'output e il file a.txt del programma.
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
main()
{
struct scheda{
char nome[10];
char cognome[10];
char tel[8];
};
struct scheda a;
int fd;
fd=open("/home/nameless/Scrivania/a.txt",O_RDONLY);
read(fd,&a,sizeof(struct scheda));
printf(" 1 %s\n 2 %s\n 3 %s \n",a.nome,a.cognome, a.tel);
close(fd);
}
file a.txt:
ciccio bianchi 02929292
akajsidu iaoaia 01827622
output:
1 ciccio bianchi 02929292
2 bianchi 02929292
3 02929292
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
main()
{
struct scheda{
char nome[10];
char cognome[10];
char tel[8];
};
struct scheda a;
int fd;
fd=open("/home/nameless/Scrivania/a.txt",O_RDONLY);
read(fd,&a,sizeof(struct scheda));
printf(" 1 %s\n 2 %s\n 3 %s \n",a.nome,a.cognome, a.tel);
close(fd);
}
file a.txt:
ciccio bianchi 02929292
akajsidu iaoaia 01827622
output:
1 ciccio bianchi 02929292
2 bianchi 02929292
3 02929292