Hi I\'m not familiar using character arrays, so it is giving meproblems here, so
ID: 3613414 • Letter: H
Question
Hi I'm not familiar using character arrays, so it is giving meproblems here, so please what do I need to do? ThanksThis is an example
#include<stdio.h>
int main(void)
{
char meetday[3];
int count = 3;
printf(" Below are thea.m or p.m info for the meeting time of the associated group oractivity ");
printf("----------------------------------------------------------------------------- ");
printf(" Enter 'p' for first group meeting time p.m ");
printf(" Enter 'p' for second group meeting time p.m ");
printf(" Enter 'p' for third group meeting time p.m ");
for(index=0;index<count;index++)
{
scanf("%c", &meetday[index]);
//THE LOOP IS NOT WORKING, AS SOON AS I ENTER FIRST P THENTHE LOOP TERMINATE. I CAN'T FIGURE OUT WHAT I'M DOING WRONG
}
Explanation / Answer
please rate -thanks first problem, you're missing a declaration for index 2nd problem when reading characters the enter is left in theinput buffer so it must be "flushed" out #include #include int main(void) { char meetday[3],ch; int count = 3; intindex; printf(" Below are thea.m or p.m info for the meeting time of the associated group oractivity "); printf("----------------------------------------------------------------------------- "); printf(" Enter 'p' for first group meeting time p.m "); printf(" Enter 'p' for second group meeting time p.m "); printf(" Enter 'p' for third group meeting time p.m "); for(index=0;indexRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.