Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
*
*
*
*/
#include <ll/i386/cons.h>
#include <drivers/keyb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main
(int argc
,char *argv
[])
{
char buffer
[256];
FILE
*fin
;
char *s
;
int res
;
int c
,n
;
char ch
;
/*
temp_device=bdev_scan_devices(choose_temp_callback);
if (temp_device<0) {
cprintf("can't find a filesystem to mount on /TEMP!!!\n");
return -1;
}
res=mount(temp_device,FS_MSDOS,"/TEMP",NULL);
if (res!=0) {
cprintf("can't mount XXX on /TEMP (errno: %i)\n",errno);
sys_end();
return -1;
}
*/
/*
*
*/
cprintf
("opening...\n");
fin
=fopen("/TEMP/ALFA2.TXT","r");
cprintf
("opened!\n");
if (fin
!=NULL
) {
n
=-1;
cprintf
("fscanf()ing...\n");
res
=fscanf(fin
,"number %i",&n
);
cprintf
("fscanf()ed...\n");
if (res
!=1) {
cprintf
("error on 1st fscanf() res=%i\n",res
);
return 0;
}
cprintf
("scanned number %i (exact 103)\n",n
);
s
=fgets(buffer
,sizeof(buffer
),fin
);
if (s
==NULL
) {
cprintf
("error on 1st fgets()\n");
return 0;
}
s
=fgets(buffer
,sizeof(buffer
),fin
);
if (s
==NULL
) {
cprintf
("error on 2nd fgets()\n");
return 0;
}
s
=fgets(buffer
,sizeof(buffer
),fin
);
if (s
==NULL
) {
cprintf
("error on 3rd fgets()\n");
return 0;
}
cprintf
("fscanf()ing...\n");
res
=fscanf(fin
,"line %i error letter '%c'",&n
,&ch
);
cprintf
("fscanf()ed...\n");
if (res
!=2) {
cprintf
("error on 2nd fscanf() res=%i\n",res
);
return 0;
}
cprintf
("scanned number %i (exact 205) characer '%c' (exact 'c')\n",n
,ch
);
cprintf
("closing...\n");
fclose(fin
);
cprintf
("closed!\n");
}
cprintf
("[press 'x' to exit]\n");
while ((c
= keyb_getchar
()) != 'x') ;
return 0;
}