So my friend is trying to teach my how to program in C and I'm stumped. I'm a complete beginner and he gave me something to try and do with more advanced code than what I know and understand. For what I have to do with his code he told me that I need to exclude certain characters, specifically periods and commas from names, and only allow the numbers 1 or 2 to be put in at the end of a name. So for example Josh1 would be allowed, but Josh,2 wouln't be. Is there a way I can do this? I've inserted the code below and need the help.
Code:
//headers included
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//char arrays to hold playernames and int values for various things.
int balloons,lp,cp,playonce,check;
char player[2][10];
char first[10];
//Main Function
int main (void)
{
SetupGame();
while (balloons != 0)
{
printf("There Are %d Balloons Left\n",balloons);
Player();
}
}
//SetUp Function That Sets base Peramators and gets the players names.
int SetupGame (void)
{
Game();
balloons = 10;
if (playonce == 0)
{
GameDes();
//Gets Players Names
printf("Welcome to Balloon pop\nFirst Player Enter Your Name:\n");
scanf("%s",player[0]);
do
{
Game();
GameDes();
printf("Welcome to Balloon pop\nSecond Player Enter Your Name\n");
scanf("%s",player[1]);
Game();
//Checks If The Names Are The Same.,
if (!(strcmp(player[1], player[0])))
{
check = 1;
}
}
while(check != 1);
playonce = 1;
}
This is just the piece of coding he told me that I'd need to edit, and I really appreciate the help if it can be given. I'm all out of ideas and so is he(I'm not sure if he's just lying that he doesn't know what to do, or if he's telling the truth that he doesn't).