[Solved] Name cannot be display [closed]


I have modified your code. Please see the snipet code below

#include <stdio.h>
#include <conio.h>
#define MAX 25
char welcomeMsg[]= "Please enter your name without '*' or # " ;
char errorMsg[]= "\nError, please re-type your name. ";

void main(void)
{
    int j;
    char input;
    char name[MAX];
    j=0;
    puts(welcomeMsg);

    do
    {
        input = getche();
        if(input == '*' || input =='#' )
        {
            puts(errorMsg);
            j = 0;
            continue;
        }
        name[j] = input;
        j++;
    } while ( j < MAX && input != '\r' );

    name[j] = 0;
    puts("\nYour name is");
    puts(name);
}

enter image description here

1

solved Name cannot be display [closed]