Hello i am trying to make a simple program that counts the words in a given .txt file, the .txt file will be included when running the program like: ./a.out < test.txt

I am very new to programming and this is my first program using another file, so any help would be greatly appreciated

The wordcounting part of the program is only going to count the blank spaces between the words and should be alright, but the reading of the file is were i think the problem is.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[])
{
   int c; 
   int i;
   
   FILE* fopen(const char* argc,const char* "r"); /* openign the file */
   if (fopen==0) /* error check */
      {
      printf("Could not open file!\n");
      exit(0);
      }
   
   while (argv[c] != EOF) /* word counting part, the part i think is ok */
         {
         if (argv[c]==' ')
         {
         i++;
         c++;
         }
         else
         c++;
         }
   fclose(argc);/* close file */
         
   printf("the number of words in the file are %i",i+1);/* print result */
   
   
   system("pause");/* to get the program to stay open in the program im using  (bloodshed dev-c++) */
   return 0;
am i using the correct way to opening the file? right now its not even compiling. I kinda messed that up trying to fix it, but when it did it froze when you tried to run it.
as i said any help would be greatly appreciated!
sincerly hemulen