I have a function to take in and format user input, but it keeps cutting off the input after the 3rd character.
void formatInput(char *input_variable) {
fgets(input_variable, sizeof(input_variable), stdin);
strtok(input_variable, "\n");
}
int main() {
char input_string[255];
printf("Enter input: ");
formatInput(&input_string[0]);
return 0;
}
If I enter myinput
then it gets stored as myi
. If I don't wrap it in this function, then it works perfectly fine.