created
last reply
- 5
replies
- 668
views
- 2
users
- 1
like
- 2
links
I replaced
char num1[103], num2[103];
scanf("%s %s", num1, num2);
with
char num1[203], num2[203];
scanf("%s", num1);
scanf("%s", num2);
and submitted as “C (clang 8.0)”, and got AC.
What’s the difference between clang 8.0 and gcc8.3?
I can’t explain why the buffers needed to be larger, unless the given ranges are incorrect, or there’s spaces somewhere.
As per your directions I did the same and got AC.
But I didn’t understand why increasing the buffer size makes any difference at all even though my initial buffer size was plenty for the required operation?
And for the difference between gcc and clang I found out that clang is newer and is generally more optimised and faster (superior to) than gcc.
I’ve checked, and the input is valid. There are no numbers greater the the given limits, no leading zeros, and no leading or trailing spaces.
So, I suspect something in your code!
edit: perhaps this:
char difference[strlen(num1)];
subtract(num1, num2, difference);
if num1 is ‘10’ and num2 is ‘0’, then difference will also be ‘10’ i.e. two characters. Where does the terminating null go?
Suggested Topics
Topic | Category | Replies | Views | Activity |
---|---|---|---|---|
ADV04F - Four Chips(hard) HELP! | ProblemSet Archive | 1 | 59 | 23d |
What are allowed characters in task t9 | ProblemSet Archive | 4 | 218 | Feb 24 |
Help me please! | ProblemSet Archive | 4 | 29 | 13d |
AIBOHPHOBIA - LPS vs Direct Approach | ProblemSet Archive | 1 | 114 | Mar 31 |
ABCPATH - ABC Path | ProblemSet Archive | 1 | 94 | May 11 |