Issues with several warnings.

This is a discussion on Issues with several warnings. within the C Programming forums, part of the General Programming Boards category; Hey, I have several warnings I've been trying to get rid of, but to no avail. Should I be concerned ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    9

    Issues with several warnings.

    Hey, I have several warnings I've been trying to get rid of, but to no avail. Should I be concerned with them? The program still runs fine.

    a2.c: In function ‘main’:
    a2.c:69: warning: implicit declaration of function ‘index’
    a2.c:69: warning: assignment makes pointer from integer without a cast
    a2.c:84: warning: control reaches end of non-void function

    Here is my code.


    Code:
    #include <stdio.h>
    
    #include <string.h>
    
    #include <stdlib.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 main()
    
    {
    
    
    
    char buf[1048576] , * i , * j ;
    
    
    
    i=buf;
    
    
    
    while( fgets(i, 1048576, stdin) != 0 )
    
      {
    
        if ( ( j=index(i,'\n') ) != 0 ) *j=' ';
    
        i=i+strlen(i);
    
      }
    
    
    
    printf("\n\n%s\n\n", 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));
    
    
    
    
    
    }

  2. #2
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Well your first problem is that you never created 'index', you just started using it. Compilers don't like that.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    9
    I meant the function index that checks a string for a character. I just used strchr and it fixed itself.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to solve warnings that appear when building my DLL...
    By starcatcher in forum Windows Programming
    Replies: 6
    Last Post: 12-14-2008, 10:47 AM
  2. Warnings when using vector of vector
    By Boksha in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2008, 01:54 PM
  3. Replies: 9
    Last Post: 03-14-2008, 09:55 AM
  4. map warnings and microsoft visual C++ 6.0
    By DeepBlackMagic in forum C++ Programming
    Replies: 6
    Last Post: 07-17-2003, 03:52 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21