>Unless that is, there are other probelsm that aren't showing up on the compiler I am using.
There are, but they're problems that most compilers either would not mention, or would only complain about in fascist mode. A more correct implementation would look like this:
Code:
#include <ctype.h>
#include <stdio.h>
int main ( void )
{
char input[] = "abcdefghijklmnopqrstuvwxyz";
char test[] = "aeuio";
char newname[sizeof input * 2 - 1];
int x, y, v;
int atvowel;
atvowel = 0;
v = 0;
for ( x = 0; x < sizeof ( input ) - 1; x++ ) {
for ( y = 0; y < sizeof ( test ) - 1; y++ ) {
if ( input[x] == test[y] ) {
atvowel = 1;
break; /* no need to keep checking vowel is found */
}
}
newname[v++] = input[x];
if ( atvowel == 1 && islower ( input[x] ) ) {
newname[v++] = '#';
atvowel = 0;
}
}
printf ( "%s\n", newname );
getchar();
return 0;
}
And an even better solution would utilize the standard library, thus removing a nested loop, a counter variable, and a flag:
Code:
#include <ctype.h>
#include <stdio.h>
#include <string.h>
int main ( void )
{
char input[] = "abcdefghijklmnopqrstuvwxyz";
char test[] = "aeuio";
char newname[sizeof input * 2 - 1];
int x, v;
v = 0;
for ( x = 0; x < sizeof ( input ) - 1; x++ ) {
newname[v++] = input[x];
if ( islower ( (unsigned char)input[x] ) && strchr ( test, input[x] ) != NULL )
newname[v++] = '#';
}
printf ( "%s\n", newname );
getchar();
return 0;
}
By using a function to search for the vowel, you can more easily see an easy optimization: placing the vowel search (a linear time operation) after the lower case test (a constant time operation), thus avoiding the test for a vowel if the character is not a lower case letter.
>Are there any free compilers that any of you would recommend using instead of this one?
No, that one will serve you well as long as you don't expect it to catch all of your errors. Not even Lint is a substitute for knowing what you're doing and using your brain.