Isalpha doesn't seem to work for me, any suggestions?

Howdy friends, let me jump straight into it, this is my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <cstdlib>
#include <cctype>

using namespace std;

int main(int argc, char* argv[])
{
	for(int i=1;i<argc;i++)
	{
		if(isalpha(*argv[i]));
		{
			cout << argv[i] << endl;
		}
	}

	return 0;
}

What's supposed to happen is it is supposed to take the parameters (argv) and output only the letters from a list of letters and numbers, so when I input: I 223 H a d 4 it should output:
I
H
a
d

buuut it doesn't. it actually outputs all of the letters and numbers. I'm using Visual Studio, and I'm beginning to think that this might be an IDE issue. could someone perhaps try to run this code and see what gives? thanks in advance.
Last edited on
Just tried the same code in a text editor in Ubuntu, compiled it through the command line and it works perfectly. wwwwhhhyyyyyyyyyyyyyyyyyyy?
surprised it worked on ubuntu
line 11 has a semicolon ; that shouldn't be there
Last edited on
Why are you surprised?

1
2
3
4
5
6
7
for(int i=1;i<argc;i++)
	{
		if(isalpha(*argv[i])) ; // null statement
		{ // anonymous scope
			cout << argv[i] << endl; // becomes part of the first for loop 
		}
	}

But yeah, there shouldn't be a semi-colon there.
Last edited on
I was surprised that it worked the way he wanted it to on ubuntu since yeh, line 5 is part of the first loop and presumably would have printed everything there too.
He probably wrote the same thing again instead of copying it.
aaaaand now I feel like a dufus. Thanks for the help guys, I apologise for the naivety
Last edited on
Happens to everyone ^^
Topic archived. No new replies allowed.