Hi, I need the user to enter coordinates x,y . The x needs to go in front of the number like so : x8.2 . My code works , but it accepts x8.2 just the same as 8.2x. This is not allowed to happen ie . it must reject the point if it sees the x at the end . Here is what I came up with :

Code:

#include <stdio.h>
int main(void)
{
FILE * output = stdout;
FILE * input = stdin;
char stringValue[8];
float value;
fscanf(input, "%s", stringValue);
// check last character
if (stringValue[ strlen( stringValue ) - 1] == 'x')
{
fprintf(output,"You have entered incorrect value - put the x at the front !");// wrong value
return 0;
}
else
{
fscanf(input, "%f", value);
fprintf(output,"The program will continue");
}
}

I run that , it works for any number with x at the end , it says incorrect put at x at front , but if a correct number is putin, it will crash ? If Im not doing this correctly can you show me the right way ?

Thank you