I’m getting a SIGSEGV error in my code for MAXNUM3.I’m getting the correct outputs in my IDE.Please help me.
https://www.codechef.com/viewsolution/16008594
Hey @kriskhundu
Can you tell me why have you taken array of size 100 only. The question says that the number of digits can be equal to 10^5. Your code will give a segmentation error for lengths greater than 100.
You can check this example. Here I have taken number of digit as 10^3 and it is giving me a runtime error.
I am very sorry.I did not read the question properly.I was thinking n was the number itself.
Well,increasing the size didnt help.Now i’m getting WA.
Yup, increasing the size of the array will only solve the segmentation fault. But there is an error in the logic itself. Have a look at this example: https://ideone.com/cw3wtD . You are using sscanf to get temp from num, but temp is an int variable and integer overflow condition will occur in case of number of digits greater than 10.