I've taken a break from c++ and I trying to learn c. What I think is happening here is that it's somehow promoting the char to an int because the argument that I provided is a char. What do you think is the problem? Oh, since I'm learning c, do you see anything here that is a no-no in terms of bad practice.
#include <stdio.h>
#include <ctype.h>
void skipLine()
{
scanf("%*[^\n]"); /* Skip to the End of the Line */
scanf("%*1[\n]"); /* Skip One Newline */
}
int main()
}
int x, args;
char r = 'y';
while(toupper(r) != 'N')
{
printf("Enter an integer: ");
if (( args = scanf("%d", &x)) == 0)
{
printf("Error: not an integer\n");
skipLine();
continue;
}
else
{
if(args == 1)
{
printf("Read in %d\n", x);
skipLine();
printf("\nWould you like to enter another number? [y/n]");
scanf("%c", &r); // The warning is here.
}
}
}
}