mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
extend example to test the I/O interface
This commit is contained in:
parent
f74b06d6f7
commit
ba755badb5
1 changed files with 14 additions and 1 deletions
|
@ -31,9 +31,12 @@
|
|||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define N 255
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int i;
|
||||
int i, random;
|
||||
FILE* file;
|
||||
|
||||
printf("Hello World!!!\n");
|
||||
for(i=0; environ[i]; i++)
|
||||
|
@ -41,5 +44,15 @@ int main(int argc, char** argv)
|
|||
for(i=0; i<argc; i++)
|
||||
printf("argv[%d] = %s\n", i, argv[i]);
|
||||
|
||||
file = fopen("/etc/hostname", "r");
|
||||
if (file)
|
||||
{
|
||||
char fname[N] = "";
|
||||
|
||||
fscanf(file, "%s", fname);
|
||||
printf("Hostname: %s\n", fname);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
return errno;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue