OK, my compiler is giving two warnings:
>>>> warning C4047: 'function' : 'const char *' differs in levels of indirection from 'unsigned int '
>>>>warning C4024: 'sprintf' : different types for formal and actual parameter 2
I was under the impression i could use sprintf to convert a string to an int?
I have used strtol in the past and it has always worked, but i want an INT not a LONG INT.
Here's the code:
Code:
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int iTempr, iMaxTempr, iMinTempr, iInputError;
char cBuff01[BUFSIZ];
do
{
printf("> Please enter the temperature:");
fgets(cBuff01, sizeof(cBuff01), stdin);
if (sscanf(cBuff01, "%d", &iTempr) == 1);
if (cBuff01[0] != '\n')
{
if (iTempr > iMaxTempr)
{
iMaxTempr = iTempr;
}
else if (iTempr < iMinTempr)
{
iMinTempr = iTempr;
}
iInputError = 0;
}
else
{
printf("\n\tInvalid Input. Please try again.\n\n");
iInputError = 1;
}
}while(iInputError == 1);
printf("%d", iTempr);
return 0;
}