hello.c: print arguments, no input section
authorH. Peter Anvin <hpa@zytor.com>
Sat, 16 Feb 2008 06:50:29 +0000 (22:50 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Sat, 16 Feb 2008 06:54:22 +0000 (22:54 -0800)
Make "Hello, World!" a little bit more plain, but do print out its
arguments, if any.  Useful for testing.

com32/samples/hello.c

index 4b29901..27fd7d5 100644 (file)
 #include <stdio.h>
 #include <console.h>
 
-int main(void)
+int main(int argc, char *argv[])
 {
-  char buffer[1024];
+  int i;
 
   openconsole(&dev_stdcon_r, &dev_stdcon_w);
 
   printf("Hello, World!\n");
 
-  for (;;) {
-    printf("> ");
-    fgets(buffer, sizeof buffer, stdin);
-    if ( !strncmp(buffer, "exit", 4) )
-      break;
-    printf(": %s", buffer);
-  }
+  for (i = 1; i < argc; i++)
+    printf("%s%c", argv[i], (i == argc-1) ? '\n' : ' ');
 
   return 0;
 }