C language help

Status
Not open for further replies.

c_c

Prominent
Jan 14, 2018
1
0
510
0
Hello everybody,

Is there anybody how can help to solve my assignment? I need to write c code that finds 100 most repeated words in to .txt file. I also need to use hash table or binary tree structures.

1. My first step was to figure out how to read file :


#include <stdio.h>
#include <stdlib.h>

int main(){

FILE *fp;
char filename[15], c;
printf("File name:\n");
scanf("%s", filename);

fp = fopen(filename, "r");

if (fp == NULL)
{
printf("Error \n");
return (0);
}

c = fgetc(fp);
while (c != EOF)
{
printf ("%c", c);
c = fgetc(fp);
}
fclose(fp);
return 0;
}

2. Step is how to insert every word in to hash or binary table??
Which one is easier hash or binary?



3. How to list 100 most repeated words??


thanks
 
Status
Not open for further replies.

ASK THE COMMUNITY