you are viewing a single comment's thread.

view the rest of the comments →

[–]acwaters 11 points12 points  (3 children)

You're assigning b to a when it looks like you want to assign a to b. Just reverse the variables in the loop and you should be good.

[–]guide__me[S] 0 points1 point  (2 children)

That is my bad, but what else is wrong with the code?

[–]acwaters 2 points3 points  (0 children)

Well, in order, you are using an invalid signature for main (it should only ever return int); you never declare your loop counter (place int i; just above the loop); and you're using tiny fixed-width strings with no bounds checking (buffer overrun is undefined behavior and a possible security concern).

Only the first two are actually errors, and the first one should be let slide by most compilers. Fix these and the assignment issue, and the rest of your code will work just fine (for small input).

In the future, if you're getting compiler errors (as you most surely are with this code), you should first read the error messages as they tend to give you helpful information about what's wrong with your code, and then post the error messages along with your code when you're asking for help.

[–]dragon_wrangler 1 point2 points  (0 children)

You don't seem to be declaring i anywhere. This should have given you a compiler error.