...

string

Xiang
03-03-2003, 04:46 PM
Dear sir,

I an trying to write a function to return a nonzero if the character is a vowel, or zero if it is not a vowel. But, my program shown error message, why??? Below are my codes.

#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>

void isvowel(char string[]);

void main(void)
{
char string[40];
int idx;

clrscr();

gets(string);
printf("%s", string);
isvowel(string);

getch();
}

void isvowel(char string[])
{
int idx;

for (idx=0; string[idx] != '\0'; ++idx)
{ if (isvowel(string[idx]))
putchar("<%c>", string[idx]);
else
putchar("%c", string[idx]);
++idx;
}

getch();
}


This is the actual output I wanted

Washington (input)

W<a>sh<I>ngt<o>n


Thanks

Xiang

Spookster
03-03-2003, 05:32 PM
Why do you keep incrementing your variables before you use them?

++var != var++

djdante97
03-03-2003, 08:52 PM
There's no need to increment your idx variable at the end of the for loop since it's in the update list. Also, change it from ++idx to idx++.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum