CS50 Practice Problem No Vow3ls

// Write a function to replace vowels with numbers
// Get practice with strings
// Get practice with command line
// Get practice with switch

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

string replace(int argc, string argv[1]);

int main(int argc, string argv[])
{
    string argv[1] = get_string("What is the word you want to convert? ");

    {
        if (argv == 0 || argv > 1)
        {
            printf("Missing or more than one command-line argument\n");
            return 1;
        }
        printf("%s\n", replace(argv[1]));
    }
}


string replace(int argc, string argv[1])
{
        switch (argv[i])
        {
            case a:
                printf("6\n");
                break;
            case e:
                printf("3\n");
                break;
            case i:
                printf("1\n");
                break;
            case o:
                printf("0\n");
                break;
            case u:
                printf("u\n");
                break;
        }
}

Can someone please help me out?

Hi.

  1. Y You can try not using a variable like string argv[1] in the replace() function, but instead, create another variable, for example, text (because when you write argv[1], you get a string)
  2. Also don’t need to use get_string. Because the input was already entered when you make no-vowels
  3. Maybe you need to iterate over the symbols in the replace() function or something like that
  4. The written function doesn’t return anything.
    I hope it’s helpful

Sorry, figured this out a while ago, should’ve deleted this thread. My bad

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.