I've been working on a program that inverts a word and changes the vowels in the word into an asterisk..
I'm confused on where to put the strset in my code.. can someone teach me how to?
thanks..

Here's my code.. I know it's simple but I'm just a beginner in this field.

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

char str1[25];
void main()
{printf("Enter a word:\t");
scanf("%s",str1);
 {printf("%s\n",strrev(str1));}
getch();
}

Thanks.

Edited 5 Years Ago by Ich bin würdig: n/a

I'd start by learning to format your code properly.
Then understand that main() has never been a void function. See this.
Further know that conio.h and getch() are nonstandard and should not be used. There are standard ways to do what you are trying to do.
And last, what makes you think strset() needs to be used. You only need a couple FOR loops for the entire program.

Thanks for the tips... :)
So, in the entire program, I just need to use for loops?
what should I do with the vowels? should I set an array for it? Regarding the void main(), our professor once used it so, um, I was just using it.

what should I do with the vowels? should I set an array for it?

I've always seen people write a small helper function:

#include <ctype.h>

int is_vowel(int ch)
{
    ch = tolower((unsigned char)ch);

    return ch == 'a' || ch == 'e' || ch == 'i' || 
           ch == 'o' || ch == 'u';
}

Regarding the void main(), our professor once used it so, um, I was just using it.

If your professor requires it, use it. But be aware that void main is wrong, and your professor probably doesn't know C well enough to teach it properly. Be skeptical about whatever he tells you.

This article has been dead for over six months. Start a new discussion instead.