I would like to have a function (or may be some kind of executable) that can be called via Terminal from wherever I am (from any directory) and this function does a simple job of converting between units, e.g. from meter to feet. Is such task realizable? I can code in Fortran90 and C, the former being more familiar with than the latter. I work on MacOS X platform.
For the sake of simplicity let's say that my function written in C takes a string and print it in standard output:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
char str[4];
strcpy(str, argv[1]);
printf("input = %s \n",str);
}
Then compiling it to generate an executable named "example". I would like to be able to call this program globally, so that by executing $example abc it will print input = abc in the terminal window. I have tried placing this executable under the same directory as the gcc's (gfortran, gcc, g++, etc) since this path has been set to the environment variable but it didn't work. I can't call it from outside this directory.