How to code apps in C

Orix is working with cc65. There is fopen/fread primitives and argc/argv management.

#include <stdio.h>
 
int main (int argc,char *argv[])
{
  int i;
  printf("Count argc : %d\n",argc);
  /* First argument is executable name only */
  printf("\nexe name=%s", argv[0]);
 
  for (i=1; i&lt; argc; i++)
  {
    printf("\narg%d=%s", i, argv[i]);
  }
  return 0;
}

This sample open a file and read the first char

#include <stdio.h>
#include <string.h>
 
char mychar;
 
int main (int argc, char *argv[])
{
  int nb;
  char car;
  FILE *fp;
  char *path="/usr/share/readme.txt";
  fp=fopen(path,"r");
  if (fp==NULL)
  {
    printf("Can't open %s\n",path);
    return(1);
  }	
  // display one char from file
  nb=fread(car,1,1,fp);
  printf("Char : %c\n",car);
  return 0;
}