Question:

C Help with error message: Line 30 Expected primary-expression before "int"

by Guest62620  |  earlier

0 LIKES UnLike

Here is my code so far:

// This program promts user to enter a string and then returns

// the number of vowels, consonants, and characters in the string.

#include <iostream>

#include <cstring>

int vowel_count (int i, int vow);

int consontant_count (int i, int cons);

using namespace std;

int main()

{

string str;

// Promt user to enter string

cout <<"Enter a String: '\n'";

getline (cin, str);

cout << "You entered: "<< str<< endl;

// C-String Output

cout <<"This has " << str.length();

Line 30 cout <<"characters," << int vowel_count(str);

cout <<"vowels and " << int consontant_count(str);

cout <<"consonants" <<endl;

cout <<endl;

// String Data Type Output

cout <<"This has " << str.length();

cout <<"characters," << int vowel_count();

cout <<"vowels and " << int consontant_count();

cout <<"consonants" <<endl;

cout <<end;

}

int vowel_count ()

{

int vow

for(int i = 0; i < str.length(); i )

{

if(str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u'

str[i] == 'A' || str[i] == 'E' || str[i] == 'I' || str[i] == 'O' || str[i] == 'U')

vow ;

return vow;

}

}

int consontant_count ()

{

int cons

for(int i = 0; i < str.length();)

{

if(str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u'

str[i] == 'A' || str[i] == 'E' || str[i] == 'I' || str[i] == 'O' || str[i] == 'U')

i ;

else

cons || i ;

return cons;

}

system("PAUSE");

return 0;

}

 Tags:

   Report

3 ANSWERS


  1. I suggest you use a comprehensive killing NOD

    Then clean up your registry repair documents can be resolved

    Please visit

      http://www.Fix-pc-Master.com

    Can help you

    Good luck


  2. Haven&#039;t had the chance to learn any C yet, but from a guess:

    &quot;int vowel_count ()&quot;

    The function accepts no arguments, whilst &quot;Line 30 cout &lt;&lt;&quot;characters,&quot; &lt;&lt; int vowel_count(str);&quot; passes a single string.

    To fix this u need something like &quot;int vowel_count (string str){&quot; instead.

  3. Well, this is C++, not C.  (The two are _not_ the same.)

    The problem here:

    cout &lt;&lt;&quot;characters,&quot; &lt;&lt; int vowel_count(str);

    is the &quot;int&quot; before the call to vowel_count().  Simply remove it:

    cout &lt;&lt;&quot;characters,&quot; &lt;&lt; vowel_count(str);

    (Same thing for the other lines with the same error.)

    - kb -

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions