Finding and printing out repeating word from file in C

I find myself in desperate situation, cause I don't understand a darn thing about file operations. I need a C code that goes through the file and checks for repeating words, and if it finds, then it prints it out, or at least an algorithm that scans a word from file and adds it into array so that I could check if the word is repeated.
I began a little bit, but the darn file is like a BSOD screen across my brain.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define LIBFILE "./text.txt"
#define ARR 1000

char word[15][ARR];

int main()
{
    init();
    return 0;
}

int init()
{
    int a=0,b=0,c;
    FILE *fl;
    fl=fopen(LIBFILE,"r");
    while(!feof(fl))
    {
         fscanf(fl,"%s",word);


also, one of my friends told me to use (somehow -_-) this kind of piece of code:
1
2
3
4
5
6
7
8
while(!feof(ptr_file))
{
  fgets(temp,sizeof(temp),ptr_file);
  ptr = strtok (temp," ,.-!?");    
  if(strstr (ptr, word)) 
  {
	  puts(ptr);
}

Help please.
okay, I worked reeeeally hard to get this, and that's what I have, at least it's like, printing the array as a text which is in the file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
    init();
    return 0;
}

int init()
{
    int a=0,b=0,c,cc,d,e,f,i,j=0;
    char ch[20];
    char word[20][1000];
    char sign[]={' ',',','.','-','!','?'};
    FILE *fl;
    fl=fopen("text.txt","r");
    if(fl==NULL)
    {
                printf("Error 404: no file found.\n");
                system("PAUSE");
                return 0;
                }
    while(!feof(fl))
    {
         fscanf(fl,"%c",ch);
         for(d=0;d<sizeof(ch);d++)
         {
                                  for(c=0;c<sizeof(sign);c++)
                                  {
                                                             if(ch[d]==sign[c])
                                                             {
                                                                               b=b+1;
                                                                               }
                                                             }
                                  }
         cc=b;
         b=0;
         for(d=0;d<sizeof(ch);d++)
         {
                                  word[d][b]=ch[d];
                                  }
         printf("%c",word[d][b]);
         }
    printf("\n");
    system("PAUSE");
}

now what I need is somehow compare the words between them, to know what words I need to print out (aka. the ones that are repeated), little bit of help please maybe?
closed account (4z0M4iN6)
I suggest, you could meet Triinu Tammer, because it seems he has just the same problem

http://cplusplus.com/forum/beginner/70652/
Topic archived. No new replies allowed.