Regarding getw() funcion

I am using getw() to print integers from a file but unfortunately it is printing something else.

The C Program is:

     #include<stdio.h>
     #include<math.h>
      main(void)
      {
      int g;
      FILE *fp;
      fp=fopen("prob.txt","r");
      while((g = getw(fp)) != EOF)
        {
        printf("\n g:%d",g);
        }
        fclose(fp);

       }

Data inside the file are: { 13 17 23 37 43 47 53 67 73 83 97 }.

But the output are big numbers.
Why is this problem happening ?

while((getw(fp)) != EOF)
        {
        g = getw(fp);
        printf("\n g:%d",g);
        }
        fclose(fp);

       }

try this !!

#include <stdio.h>

int main ()
{

FILE *fp;
int i=1, j=2, k=3, num;
fp = fopen (“test.c”,“w”);
putw(i,fp);
putw(j,fp);
putw(k,fp);
fclose(fp);

fp = fopen (“test.c”,“r”);

while((num = getw(fp))!=EOF) //Statement 2
printf("\n%d",num);

    fclose(fp);

return 0;
}

Not working bro…!!

try this one

try bottom one

Your code is fine, but I can see that there is no integer inside test.c.But instead written SOH. Why its not working when I am reading a text or dat file
containing some integers already ?

#include<stdio.h>
int main () {

FILE *fp; 

fp = fopen ("test.c","r");
int num;
while((num = getw(fp))!=EOF)
	printf("\n%d",num);

fclose(fp);
return 0;

}

This much code is also working fine

I just tested this code also but…the same problem again.
not printing the actual integers.
But printing some big integers.
I am using Code Blocks 16.01.

You have tried to help me a lot.
Though the issue has not been solved, I am really thankful to you for your efforts.
Thanks.