Explore BrainMass

Recognize Digit String Surrounded by Optional White Spaces

This content was STOLEN from BrainMass.com - View the original, and get the solution, here!

Char line [MAXLINE];
int error,;
do {
printf("Input a positive integer: ");
fgets(line, MAXLINE,stdin);
error=sscanf(line,"%d",&n) !=1II n<=0;
printf("|nERROR:Do it again.n");
} while(error);

© BrainMass Inc. brainmass.com September 24, 2018, 12:05 am ad1c9bdddf - https://brainmass.com/computer-science/files/recognize-digit-string-surrounded-by-optional-white-spaces-95252

Solution Preview

I assume that you do it in C (so the code looks).

An example of how to modify the code to do what you request is given below.

In case you do it in Visual Studio, I also attach a whole VS6 project in the zip file (it can easily be modified for VS7 and VS8, if needed).
It is worth to look into it in any case, as some of the characters used in ...