forked from Bananymous/banan-os
Userspace: Simple stdio test
This commit is contained in:
parent
46dcf98fc1
commit
7fac2a7526
|
@ -2,7 +2,32 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
if (printf("Hello %s!", "World") == -1)
|
||||
perror(NULL);
|
||||
FILE* fp = fopen("/boot/grub/grub.cfg", "r");
|
||||
if (fp == NULL)
|
||||
{
|
||||
perror("fopen");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
char buffer[128];
|
||||
size_t nread = fread(buffer, 1, sizeof(buffer) - 1, fp);
|
||||
if (nread == 0)
|
||||
{
|
||||
if (ferror(fp))
|
||||
perror("fread");
|
||||
break;
|
||||
}
|
||||
buffer[nread] = '\0';
|
||||
fputs(buffer, stdout);
|
||||
}
|
||||
|
||||
if (fclose(fp) == EOF)
|
||||
{
|
||||
perror("fclose");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue