Step 1: Write following code.
#include <stdio.h>
void main (int count,char * argv[])
{
int i;
FILE *ptr;
char *str;
char ch;
if (count==1)
{
printf("The syntax of the command is incorrect.\n");
}
for (i=1;i<count;i++)
{
ptr=fopen(argv[i],"r");
if (ptr==NULL)
{
printf("The system cannot find the file specified.");
if (count>2)
printf("\nError occurred while procesing : %s.\n",argv[i]);
}
else
{
if (count>2)
{
printf("%s\n\n",argv[i]);
}
while ((ch=getc(ptr))!=-1)
printf("%c",ch);
}
fclose(ptr);
}
}
Step 2: Save the as open.c (You can give any name)
Step 3: Compile and execute the file.
Step 4: Write click on My computer of Window xp/ vista/ win 7/8.
operating system and select properties.
Step 5: Select Advanced -> Environment Variables
Step 6: Click on new button.
Step 7: Write following:
Variable name: path
Variable value: c:\tc\bin\open.c (the path where you have saved)
Step 8: Open command prompt and write open then file name and press enter button.