Hi fellas, I have a problem when I try to count every vowel in a txt file. Input and output when dealing with txt files is no problem. But in my program, I have to generate random ascii characters and put them inside a txt file. Then I have to count every vowel in every line. I can count all of them: capital and noncapital. But how can I make my program count all of the vowels, including those with strange simbols like '¨´' or any other?
An ordinary char is a narrow type - they are straight ASCII chars, and doesn't have those accent marks. So an easy answer is to fill your file with these.
On the other hand a wchar can hold all kinds of chars.
If you use a switch statement, you can have a case which has all the chars you deem to be a vowel.
Really? But I've already defined my characters as "char" and I still get strange symbols. However, I've already made a very long "if statement" to count some vowels like "ä" and others. But it's too long and there's probably a better way to do that. Does anyone know how?
Generally, when you refer to "ASCII" characters, you're referring to those printable characters with values in the range [0,128) Characters outside that range are "extended ASCII" characters, and differ according to the environment you're in. (So, if you're using a different environment at school and home you may not get the same results.)
However, you could extend the following for your dubious goal if you wished: