Hey guys!i just started learning c++ programming and i am stuck on a problem.
The problem is I have to implement selection construct and continue the loop and i am not sure where to put my continue; at if i want the user to re-type his/her name. Thanks for helping :)
#include <stdio.h>
#include <conio.h>
#define MAX 25
char welcomeMsg[] = "Please enter your name without * or #";
char errorMsg[] = "Error please re - enter your name without * or #"; //error message
void main(void)
{
int j;
char name[MAX];
char selection;
char input;
j = 0;
puts(welcomeMsg);
It is pretty much C code. Inputting a complete name with _getch() may be difficult. That's why functions for inputting a large number of characters at a time exist for that purpose (cin, scanf, etc), and you really should use them instead.
For checking if there is an invalid character in your name, use strchr (at least it's basic)
I've seen you give this advice twice now. This is a thing you should never do. Use a C++ string, or, at the very least, limit the amount of characters extracted by cin. You're just asking for a buffer overflow here.