u/112365365321 - 2 Archived Voat Posts in v/programming
u/112365365321
  • home
  • search

u/112365365321

0 posts · 2 comments · 2 total

Active in: v/programming (2)

  • ‹‹‹
  • ‹‹
  • ‹
  • 1
  • ›
  • ››
  • ›››
Comment on: Newbie question regarding OOP

Java: Walls and Mirrors is a good book for OOP Java, which is similar to C#. The OOP way should still carry on to most languages, there is just a difference in syntax. It also contains more of an explanation as to why you would use OOP, its purpose and also includes information on separating implementation from interface. Like others have mentioned, there isn't a "right" way, but to choose a specific answer for your question the preferred OOP way is generally the 2nd versions of what you posted.

1 28 Jun 2015 16:35 u/112365365321 in v/programming
Comment on: I can't wrap my head around this bug...

In your print statements, why did you use %s for a char and then pass a pointer? This seems like the most likely cause to me. Maybe try printf("%c%11c", notation, ' ');

I think that should work. I think what is happening is you are giving printf the address to a char which gets represented as an int, so effectively you are passing an int to be printed as a string. I could be wrong about that though. EDIT: Yeah, I was wrong. Thanks to /u/taxation_is_slavery for pointing this out below.

EDIT: I'd also like to add that you could even do something like: printf("%11c", notation); Although it might mess with the spacing, you might need to increment that value or something but it eliminates the need to pass the space char into the function to get it to space out. There is a width and a length flag and I'm not sure which is being used instead of which in this case, but I do know it's shorter and more efficient.

1 20 Jun 2015 06:24 u/112365365321 in v/programming
  • ‹‹‹
  • ‹‹
  • ‹
  • 1
  • ›
  • ››
  • ›››

archive has 9,592 posts and 65,719 comments. source code.