I have a simple program which receives input from 3 different functions, 2 return ints, 1 returns a char, but the third function doesn't scanf for some reason it skips that step entirely.
#include <stdio.h>
int get_height();
int get_length();
char get_symbol();
void draw_rectangle(int h, int l, char s);
int main () {
int h, l;
char s;
h = get_height();
l = get_length();
s = get_symbol();
draw_rectangle(h, l, s);
return 0;
}
int get_height() {
int i;
printf ("Please enter the height of the rectangle: ");
scanf ("%d", &i);
return i;
}
int get_length() {
int i;
printf ("Please enter the length of the rectangle: ");
scanf ("%d", &i);
return i;
}
char get_symbol() {
char i;
printf ("Please enter the symbol for the rectangle: ");
scanf ("%c", &i);
return i;
}
void draw_rectangle(int h, int l, char s) {
printf ("%d %d %c", h, l, s);
}
When I run this, i can scan for height and length but it prints the prompt to scan for the char but then skips the user input and prints the value for h and l but no s. What am i missing here?