Don't know what is wrong with this, it's giving me an error on the 'if (isalpha(string))' line..I had it working earlier but then decided to put it into a function and it's not working now. It's giving the error "expected primary-expression before '[' token " for that line and the one below it. Any ideas on what i've left out? The program is fairly simple. Takes in a string and I just wanna look at any words in that string...so far I only output the characters but i'll transfer them into an array or something later for use. Cheers to anyone who solves this stupid error for me..


using namespace std;

void trim(char string[], int num);

int main()
    char string[20];
    cout << "Input a string: " ;
    cout << "You input: " << string;    
    trim(string, 20);

void trim(string[], int num)
           for(int i=0; i<num; i++)
              if (isalpha(string[i]))
                   cout << string[i];
9 Years
Discussion Span
Last Post by Narue
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.