3 Replies - 1216 Views - Last Post: 16 November 2013 - 05:13 PM Rate Topic: -----

#1 SonicSoundVW  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 05-November 13

problem, called object type not a function or function pointer?

Posted 16 November 2013 - 04:52 PM

My code will not compile due to 2 errors. called object type 'char *' is not a function or function pointer and expected unqualified-id. i have moved the brackets and to be honest, with my limited knowledge, i honestly don't see what is wrong. If somebody could point me in the right direction and or give any advice about my code it would be greatly appreciated. Thank you in advance. :-)


#include <iostream>

using namespace std;

int sentenceCount (char[]);

void allCap(char[], int);

void displaySentence(char []);

void numVowels(char [], int&, int&, int&, int&, int&);

void reverseSentence(char [],char []);





int main()
{
    const int SIZE = 50;
    char sentence[SIZE];
    char reverseSentence[SIZE];
    
    int a, e, i, o, u;
    int howMany = 0;
    
    cout << "Please enter a sentence of no more than" << endl;
    cout << (SIZE -1) << " characters:\n";
    
    cin.getline(sentence, SIZE);
    
    cout << endl;
    
    cout << "The sentence you entered  is:\n";
    
    displaySentence(sentence);
    
    cout << endl << endl;
    
    howMany = sentenceCount(sentence);
    
    cout << "There were " << howMany << " charcters entered." << endl;
    
    cout << endl;
    
    allCap(sentence, howMany);
    
    cout << "This is what the sentence would look like" << endl;
    cout << "with all capital letters: " << endl;
    
    displaySentence(sentence);
    
    cout << endl << endl;
    
    numVowels(sentence, a, e, i, o, u);
    
    cout << "This sentence contains:" << endl;
    cout << a << " As " << e << " Es " << i << " Is ";
    cout << o << " Os and " << u << " Us " << endl << endl;

    reverseSentence(sentence, reverseSentence); //This is marked with the called object type 'char *' is not a function or function pointer
    
    displaySentence(reverseSentence);
    cout << endl;
    
    return 0;
}

int sentenceCount (char array[])
{
    int howMany = 0;
    int count = 0;
    
    while (array[count]!='\0'){
        howMany ++;
        count++;
    }
    return howMany;
        
}

void allCap(char array[], int numChar)
{
    for (int i = 0; i < numChar; i++)
        
    {
        if((array[i] >= 97) && (array[i] <= 122)) // checking if character is lowercase.
            
            array[i] -= 32; // convert to uppercase.
    }

}

void displaySentence(char array[])
{
    int count = 0;
    
    while (array[count] != '\0')
    {
        cout << array[count];
        count++;
    }

}

void numVowels(char array[], int &a, int &e, int &i, int &o, int &u)
{
    int let = 0;
    
    while (array[let] != '\0')
    {
        if (array[let] == 'A')
        {
            a++;
            let++;
        }
        else if (array[let] == 'E')
        {
            e++;
            let++;
        }
        else if (array[let] == 'I')
        {
            i++;
            let++;
        }
        else if (array[let] == 'O')
        {
            o++;
            let++;
        }
        else if (array[let] == 'U')
        {
            u++;
            let++;
        }
        else
        let++;
    }
    
        
}

void reverseSentence(char origional[],char reversed[]);
{ // < that curly brace is highlighted for the  expected unqualified-id

    int count = sentenceCount(origional);
    int i = 0;
    

    for (count - 1; count >= 0; count--)
        {
        reversed[i] = origional[count];
        i++;
        }
}



Attached image(s)

  • Attached Image
  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: problem, called object type not a function or function pointer?

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4333
  • View blog
  • Posts: 12,128
  • Joined: 18-April 07

Re: problem, called object type not a function or function pointer?

Posted 16 November 2013 - 05:05 PM

Well first of all you need to get rid of that semi-colon after the closing parenthesis...

void reverseSentence(char origional[],char reversed[]); //<--- Get rid of that semicolon
{
  ....
}



That semicolon there is saying that the function has one line in the body, a null statement. So it is not seeing the { } code as being part of that function.

See if that fixes it. :)
Was This Post Helpful? 1
  • +
  • -

#3 SonicSoundVW  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 05-November 13

Re: problem, called object type not a function or function pointer?

Posted 16 November 2013 - 05:08 PM

OH MY GOODNESS!!! i think I've been working on this too long today, thanks for pointing that out! good grief. although i am still getting the called object type error.
Was This Post Helpful? 0
  • +
  • -

#4 SonicSoundVW  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 05-November 13

Re: problem, called object type not a function or function pointer?

Posted 16 November 2013 - 05:13 PM

Never mind guys, i found the problem, had the function and the array with the same name.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1