I'm really new to C. i posted a problem with my code yesterday that i was able to fix thanks a lot.
All my program is in the main though and i want to create functions. i can't seem top pass the array down to te function. could someone show me how to do one so i can do the other thanks a lot.
this is what i want to make a function:
for(k = 0; k < 40; k++)
{
if (open >= close) break;
if (cLunch == open)
{
patient_string[k] = "***At Lunch***";
open++;
}
else if (cMeeting == open)
{
patient_string[k] = "***Meeting***";
open++;
}
else
{
printf( "How many patients had you between %d", open);
open++;
printf(":00 and %d:00: ", open);
scanf("%d", &patients);
patient_int[k] = patients;
}
}
this is all y code:
#include <stdio.h>
#include <string.h>
int main()
{
int open, close, o, c, cLunch, cMeeting;
char holder;
int patients; // padding out with h
char *patient_string[20] = {"h","h","h","h","h","h","h","h","h","h","h","h","h","h","h","h","h","h","h","h"};
int patient_int[100] = {0};
int k, x = 0;
printf("what time do you open ");
open = 9; //scanf("%d",&open);
printf("what time do you close ");
close = 15; //scanf("%d",&close);
o = open;
c = close;
printf("What time does your surgery close for lunch: ");
cLunch = 12; //scanf("%d",&cLunch);
printf("Is there a meeting, Y or N: ");
holder = 'y'; //scanf("%s",&holder);
if (holder == 'y' || holder == 'Y')
{
printf("what time do you have your meeting: ");
cMeeting = 9; //scanf("%d",&cMeeting);
}
for(k = 0; k < 40; k++)
{
if (open >= close) break;
if (cLunch == open)
{
patient_string[k] = "***At Lunch***";
open++;
}
else if (cMeeting == open)
{
patient_string[k] = "***Meeting***";
open++;
}
else
{
printf( "How many patients had you between %d", open);
open++;
printf(":00 and %d:00: ", open);
scanf("%d", &patients);
patient_int[k] = patients;
}
}
for(x = 0; x < 40; x++)
{
if (patient_string[x] != "h")
{
printf("%d:00 - ",o);
o++;
printf("%d:00",o);
printf(" %s\n", patient_string[x]);
}
if (patient_int[x] != 0)
{
printf("%d:00 - ",o);
o++;
printf("%d:00",o);
printf(" %d\n", patient_int[x]);
}
if (patient_string[x] == "h" && patient_int[x] == 0) break;
}
return 0;
}