Confused myself more than ever
Hello everyone, I'm in the process of trying to code a program that catalogues baseball cards. The information for the cards is populated through user input. After 10 cards have been populated the user has the option to print the cards to the console, or quit. I've confused myself more than ever on this one now and I can't seem to get the populate function working correctly. I'm not looking for a solution, but more for someone to steer me in the right direction.
Code:
#include"stdafx.h"
#include<stdlib.h>
#include<stdio.h>
typedefstruct{
char lName[20], fName[20], bats, throws, team[30];
int weight, height, year, games, runs, hits, RBI;
double BA;
}Player;
Player p;
void populatePlayer (Player p);
void askPrint (Player p);
void printPlayer (Player p);
int_tmain(intargc, _TCHAR* argv[])
{
populatePlayer(p);
}
void populatePlayer(Playerp){
printf("Enter last name: ");
scanf_s("%c", &p.lName);
printf("Which hand does player bat? ");
scanf_s("%c", &p.bats);
printPlayer(p);
}
/*void askPrint(Player p){
char choice;
printf("Print data? (y/n) ");
scanf_s("%c", &choice);
switch(choice)
{
case 'y':
printPlayer(p);
case 'n':
break;
}
}*/
void printPlayer(Playerp){
printf("last name is %s\n", p.lName);
if(p.bats == 'l')
printf("player bats lefty\n");
elseif (p.bats == 'r')
printf("player bats righty\n");
else
printf("player uses some odd hand\n");
}
I appreciate any tips or guidance. Thanks in advance!