I've been trying to read characters from the keyboard using 'getchar()' but my code always misses one character. Can anyone tell me why this is
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
char string[50];
int i;
printf("Enter a string: ");
for (i=0; i < strlen(string); i++){
string[i] = getchar();
}
printf("%s", string);
}