Can someone explain what i am doing wrong..I am new to C and trying to print out the hexadecimal, decimal, etc. to the ouput but I get the same output for each character I type in which obviously isn't right. I am not declaring the c as a constant anything so im not sure why it's not working. Could someone give me suggestions please?? Thanks
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main (void)
{
char buffer [BUFSIZ] ;
char c[5];
printf ("Enter Character: ");
fgets (buffer, BUFSIZ, stdin) ;
if ( buffer [strlen (buffer)] == '\n')
buffer [strlen(buffer)] = '\0' ;
while(gets(c) != NULL)
{ puts(c);
printf("hexadecimal integer using lower case a to F: %x\n", c);
printf("hexadecimal integer using upper case A to F: %X\n", c);
printf("Decimal Number: %u\n", c);
printf("octal long: %lo\n", c);
printf("hex short: 0x%hx\n", c);
getchar () ;
return 0 ;
printf("\n");
}
}