a_slow_descent's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
7 (0.01 per day)
Joined:
01-October 12
Profile Views:
74
Last Active:
User is offline Oct 19 2012 04:49 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   a_slow_descent has not set their status

Posts I've Made

  1. In Topic: how to ignore certain characters in an array

    Posted 1 Oct 2012

    so i did the debugging and its not going as i plan. when it does scanf i enter words. i put: noon racecar? noon?
    it went through the while loop until j was 4 then it went down to my is_palindrome function. did the rest of the stuff in the main then back to the while loop. i thought it would go back to zero once it came back to here but it said j was 5 and then when it got to 8, it went to my is_palindrome. then the rest of the functions. then back to the while loop. it didn't even do anything. it just went right to the is_palindrome function. does this make sense to you?
  2. In Topic: how to ignore certain characters in an array

    Posted 1 Oct 2012

    so i am still having one problem with this. when i put input of: noon? noon noon noon?
    it only reads it as 3 palindromes. still says 8 vowels and two vowels per word. it counts the first word with a punctuation mark and doesn't for the following ones. why could this be?
  3. In Topic: how to ignore certain characters in an array

    Posted 1 Oct 2012

    Jim. I love you. thank you for all the help man. it worked when i did this:

     while(scanf("%s",word)==1)
      {
        while(word[j]!='\0')
          {
            if(word[j]==','||word[j]==';'||word[j]=='.'||word[j]=='!'||word[j]=='?')
              word[j]='\0';
              ++j;
          }
    
    


    it makes perfect sense too. thank you for explaining and not just giving me the answer. works perfectly. example of output:

    write out some words: I am racecar? nnnnooonnnn eeeeeiiieeeee
    the number of palindromes is: 3
    the number of vowels is: 21
    the average number of vowels per word is: 4.200000
    the number of words with at least 3 vowels: 3
    the number of words of length 10: 0
    the number of words of length 11: 1
    the number of words of length 12: 0
    the number of words of length 13: 1
    the number of words of length 14: 0
    the number of words of length 15: 0

    before it would say that racecar? was not a palindrome. thank you again.
  4. In Topic: how to ignore certain characters in an array

    Posted 1 Oct 2012

    Quote

    Did you read all of my last post? I told you why you are not ignoring the punctuation marks.

    Jim


    yeah i read it. i changed to look like this:

     while(scanf("%s",word)==1)
      {
        for(j=0;j<=MAX_LEN;j++)
          {
            if(word[j]==','||word[j]==';'||word[j]=='.'||word[j]=='!'||word[j]=='?')
              j='\0';
          }
    
    


    you said to do another while loop instead of the for loop? the first while loop skips the leading white space characters then reads the array until it gets to another white space character then auto puts \0 and the end of the array. im lost.
  5. In Topic: how to ignore certain characters in an array

    Posted 1 Oct 2012

    Jim. i will show you my entire main. everything works perfect except for when i add in the part to try to ignore the five punctuation marks.

    int main(void)
    {
      char word[MAX_LEN];
      int i,j,k,x,vowel=0,length=0,numPals=0,getchar(),totalWords=0,three_vowel_min\
    =0,arr[LEN_OF_WORDS]={0};
      float average_vowel=0;
      printf("write out some words: ");
      while(scanf("%s",word)==1)
      {
        for(j=0;j<=MAX_LEN;j++)
          {
            if(word[j]==','||';'||'.'||'!'||'?')
              j='\0';
          }
     if(is_palindrome(word))
      {
     numPals++;
      }
     x=vowel_count(word);
     totalWords++;
     vowel=x+vowel;
    
     if(x>=3)
       three_vowel_min++;
     for(i=10;i<=15;i++)
       {
         if(strlen(word)==i)
           arr[i-10]++;
       }
    
    
     }
      average_vowel=((float)vowel/(float)totalWords);
      printf("the number of palindromes is: %d\n",numPals);
      printf("the number of vowels is: %d\n",vowel);
      printf("the average number of vowels per word is: %f\n",average_vowel);
      printf("the number of words with at least 3 vowels: %d\n",three_vowel_min);
      for(i=10;i<=15;i++)
        printf("the number of words of length %d: %d\n", i,arr[i-10]);
      return 0;
    }
    
    
    


    i have no clue why or how the ignoring the punctuation marks works. like i said, what i wrote logically made sense to me but clearly i was wrong.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

a_slow_descent hasn't added any friends yet.

Comments

a_slow_descent has no profile comments yet. Why not say hello?