Wrong Answer

user01 Reply 9 years 31 weeks ago
Input and output matches. Why is it wrong?
pichulia Reply 9 years 31 weeks ago
why did you use this code? if(strlen(s) <= 6) {
user01 Reply 9 years 31 weeks ago
if the string had more than 6 characters it would be regarded as not hex decimal and display "null"
pichulia Reply 9 years 31 weeks ago
strlen 0xABCDEF'\n' will return 7. 0xABCDEF(EOF) will return 6.
user01 Reply 9 years 31 weeks ago
I was trying to write strlen that is more than 6,because hex decimal is 0x13a'\n' returns 6 and I think 0xABCDEF(EOF) returns 8
pichulia Reply 9 years 31 weeks ago
Ah, sorry. 0xABCDEF'\n' will return 9. 0xABCDEF(EOF) will return 8 and both data are hexadecimal. and your code will say they are "null" if input is 0xABCDEF. you must print 11259375, not null.
user01 Reply 9 years 31 weeks ago
but the Sample Output says it should be displayed as null
pichulia Reply 9 years 31 weeks ago
look carefully. sample input is 0XABCDEFG. not 0XABCDEF AND. I can SURELY say that, the length of string doesn't matter to decide that string is hexadecimal or not.
pichulia Reply 9 years 31 weeks ago
Extreme example, 0x981629846137952794861A93746127936912763491 is hexadecimal. and 0xx is not hexadecimal. Still do you want to use this code? if(strlen(s) <= 6) {
user01 Reply 9 years 31 weeks ago
I removed the if function that checked for the string length but i am still getting a wrong answer
user01 Reply 9 years 31 weeks ago
I got it. Thank you