Hi, i'm getting several warnings and erros upon adding a function to my program and I am not entirely sure as to what they are, any ideas?
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int wordcount( char words[])
{
int j=0 , wcnt = 0, lenght;
j=strlen(words)-1;
while( strchr(" \t", words[j]) != 0 ) { words[j]=0 ; j-- ; }
j=0 ;
while( strchr(" \t", words[j]) != 0 ) j++;
words=words+j;
lenght = strlen(words) ;
for(j=0; j<=lenght; j++ )
if( strchr(" \t", words[j]) != 0 ) {
while( words[j+1]==' ' || words[j+1]=='\t' ) j++ ; wcnt++ ; }
/* At the EOF strchr() returns as if it matched ! */
return(wcnt);
}
int sylcount( char * words )
{
int i , j , sylc=0, length=strlen(words);
char * vowels="AEIOUYaeiouy";
for(j=0 ; j<=length ; j++){
i=j;
while( j<= length && strchr(vowels, words[j]) != 0 ) j++ ;
if( 1<j-i ){ sylc++ ; i=j; }
}
return(sylc);
}
int sentencecount( char * sentence)
{
int j , sencnt = 0, lenght = strlen(sentence);
char *sentenders = ".;:?!" ;
for(j=0; j<=lenght; j++ )
if( strchr(sentenders, sentence[j]) != 0 ) sencnt++;
/* At the EOF strchr() returns as if it matched ! */
return(sencnt);
}
int indexcalc(int wcnt, int sylc, int sencnt)
{
int IDX;
IDX = 206.835 - 84.6 * (sylc/wcnt) - 1.015 * (wcnt/sncnt);
return(IDX);
}
int main()
{
char buf[1048576] , * i , * j ;
i=buf;
while( fgets(i, 1048576, stdin) != 0 )
{
if ( ( j=strchr(i,'\n') ) != 0 ) *j=' ';
i=i+strlen(i);
}
printf("\n\n%s\n\n", buf);
printf("Index is: %d\n", indexcalc(buf));
printf("Number of words: %d\n", wordcount(buf));
printf("Number of sylables: %d\n", sylcount(buf));
printf("Number of sentences: %d\n", sentencecount(buf));
}
a2.c: In function ‘main’:
a2.c:86: warning: passing argument 1 of ‘indexcalc’ makes integer from pointer without a cast
a2.c:58: note: expected ‘int’ but argument is of type ‘char *’
a2.c:86: error: too few arguments to function ‘indexcalc’
Any help would be appreciated, i've been playing with this for 3 days now.