When compiling my code below, it says that f
is uninitialized. How do I initialize a character and why do I need to? My intention is to end the loop when f
is entered and stored in c
.
#include <stdio.h>
#include <string.h>
int main(void)
{
int count= 0;
char c,f;
printf("Input a character:\n");
do
{
c = getchar();
count++
}while(c!=f);
printf("number of characters: %d", count);
return 0;
}