I was trying to write a simple program to convert a number to its hexidecimal equivalent. Easy enough, I got that much. The problem comes in when I want it to loop, depending on the user's answer to the last question, either y (for yes, and to continue the loop) or anything else to end the program.
Here's my coding so far:
#include <stdio.h>
main ()
{
char answer, number;
answer= 'y';
do{
printf("\nEnter in the number you wish converted to hexidecimal: ");
number = getchar();
Printf("\nThe hexidecimal representation of %c is 0x%00x.", number, number);
printf("\nDo you wish to enter in a new number? Press y for yes, any other key to exit.", answer);
answer = getchar();
}
while (answer='y');
return 0;
}
Any ideas as to what I'm doing wrong here? It's somewhere in the loop, I know that, because it works perfectly fine without the loop.