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..
#include<iostream>
#include<fstream>
#include<cstring>
using namespace std;
void trim(char string[], int num);
int main()
{
char string[20];
cout << "Input a string: " ;
gets(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];
}
}
cin.get();
}