hi guys i need help. In fact it's an assignment. I'm fed up with this stuff. This is my code. has got many errors. actually it's just messy. please provide me with me a code

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

#define MAXWORDS 5000 /* max no of word that can be read */
#define MAXLEN 25  /* max word length */

char *lines[MAXWORDS]; /* pointers to lines of text */
int freq[MAXWORDS] = {0};


bool is_present(char *lines[], int line_cnt);  
int get_word(char *, int); /* pointer to a single line of text */
int read_lines(char *lines[], int line_cnt);
void write_words(char *lines[], int line_cnt);

int main(void)
{ 
  FILE *fs;
  int line_cnt; /* no of lines read */

  if (fs = (fopen(/home/gamo/Downloads/shakespeare.txt, "rb")) == NULL)  {
    fprintf(stderr, "no source file");
    exit(0);
  }
   else if ((line_cnt = read_lines(lines, MAXWORDS)) >= 0) /* was read successfully */
    write_words(lines, line_cnt);
  else
    printf("Error: Input too big\n");
}
int read_lines(char *lines[], int maxlines) {
  int len; /* length of current line */
  int line_cnt = 0; /* no of lines read */
  char line[MAXLEN];   /* line will hold the line read */
  char *p;     
  
  while ((len = get_word(line, MAXLEN)) > 0)
  /* signal error if line_cnt > MAXLINES or system runs out of memory for array*/
    if ((line_cnt >= maxlines) || (p = malloc(len * sizeof(char))) == NULL)
      return -1;
    else if(is_present) ;

    else if(!is_present) {
      strcpy(p, line);  /* copy line into allocated space */
      lines[line_cnt++] = p; /* place pointer to line in array */
      freq[line_cnt]++;
   }
   return line_cnt;
}

void write_words(char *lines[], int line_cnt) {
  int i;
   
  for (i = 0; i < line_cnt; i++)
    printf("%s\n", lines[i]);
}

int get_word(char line[],int maxline) {
  int c, i;
   
  for (i = 0; (i < maxline - 1) && ((c = getc(fs)) != EOF) && (c != '\n') && (c != ' ') && (c != '\t'); ++i)
    line[i] = c;
    if (c == '\n')
      line[i++] = c;
  line[i] = 0;

  return i; /*  return line length */
}


bool is_present(char *lines[], int line_cnt)
{
   int i;
   
   for (i = 0; i < line_cnt; i++)
     if (strcmp(p , lines[i]) == 0) {
       ++freq[i];
       return true; 
      }
     else 
       return false;
}

hi guys i need help.

Really? I was wondering why you joined.

In fact it's an assignment.

Really? Why else would you have come here?

I'm fed up with this stuff.

Really? Why do we care? Get to the point...

This is my code.

And nice code it is. Indented nicely. Comments should probably be lined up with each other, but at least there are comments. And a line or two should be split onto multiple lines for readability.

has got many errors.

Really? I don't see any.
No compile errors listed so it can't be that.
No programming errors listed so it can't be that.
No run-time errors listed either.

And you get the prize for the most really's for the day....

actually it's just messy.

Oh, if that's all it is, make it less messy.

please provide me with me a code

Ahh, we get to the real question. You want us to do your homework for you. Got it.
The DaniWeb Homework Service is closed this week. Sorry. You're actually going to have to do it yourself, or actually ask us an intelligent question about your code and assignment.

I see a history here. Your previous post was:

Write a program that converts upper case to lower or lower case to upper, depending on the name it is invoked with, as found in argv[0].

Yet another "do my homework for me" question. The DHS must have been closed then, too.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.