example when i input hello the output will be h*ll0
How do i make a program in c language that encrypt vowel in a string?
#include %26lt;stdio.h%26gt;
#include %26lt;string.h%26gt;
void mask_vowels(char* chars, size_t len)
{
size_t i;
size_t j;
char source_chars[] = "aeiou";
char replace_chars[] = "@*!0%";
for (i=0; i%26lt;len; i++)
{
for (j=0; j%26lt;strlen(source_chars); j++)
{
if (chars[i] == source_chars[j])
{
chars[i] = replace_chars[j];
break;
}
}
}
}
int main(int argc, char* argv[])
{
// This is just to test that it works, try to replace the chars in the first command line argument and print out the results
if (argc %26gt; 1)
mask_vowels(argv[1], strlen(argv[1]));
printf("%s\n", argv[1]);
}
Just make source_chars and replace_chars are the same size if you change them.
Reply:Create a function that will accept a string and return another string. The function will examine the passed string byte-by-byte. A case structure can echo non-vowels to the return string and replace vowels in whatever manner you want - either a 1-for-1 replacement with the same character replacing the same vowel each time or a random replacement. When the entire passed string has been processed, return the modified string.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment