Conversation

Notices

  1. Hey... I'm Fluttershy. I saw this site and made an account. I hope you don't mind...

    Tuesday, 05-Apr-11 01:06:59 UTC from web
    1. @mostapplethingofall Did you ever figure out why that won't work? It's because you're adding an int to a string. You need to convert the int to a string.

      Monday, 27-Aug-12 20:42:08 UTC from web
      1. @minti 2+apple

        Monday, 27-Aug-12 20:44:22 UTC from web
    2. @mostapplethingofall Then convert it as such, cause natively strings are just arrays of bytes. Adding an int to an array of bytes doesn't exactly do anything the compiler understands.

      Monday, 27-Aug-12 20:49:23 UTC from web
    3. @mostapplethingofall Then make it a char (that's only one byte wide, whereas an int is usually about 4), and append that to the string. Either way, string + int does _not_ go.

      Monday, 27-Aug-12 20:49:47 UTC from web
      1. @bitshift Hah.

        Monday, 27-Aug-12 20:50:26 UTC from web
    4. @mostapplethingofall Actually int is 4 bytes, signed. And array + byte = compiler error, unless you're using C++/Vectors. You'll need to fill a buffer with the first part of a string then memcpy the int into it or something.

      Monday, 27-Aug-12 20:53:35 UTC from web
      1. @mostapplethingofall Yeah, this. Was typing up much the same, but @minti already said it all.

        Monday, 27-Aug-12 20:58:00 UTC from web
    5. @greydragon412 I doubt they'll even teach real programming, to be honest. xD

      Monday, 27-Aug-12 20:56:24 UTC from web
    6. @mostapplethingofall Yeah, considering it's a bit mask xD. Here, you could try this. (Warning: I only know C through memory hacking sooo this is probably the worst way to do it..) http://pastebin.com/aBzZP4i7

      Monday, 27-Aug-12 21:00:14 UTC from web
      1. @minti Wait why didn't I just use direct assignment. Derpher.

        Monday, 27-Aug-12 21:03:11 UTC from web
        1. @minti http://pastebin.com/nAAZmDux Yay pointers

          Monday, 27-Aug-12 21:07:24 UTC from web
    7. @mostapplethingofall Sadly, no compiler errors != working. For example, because a string is actually a char pointer, C will happily add an int to it, but what's actually going on will be pointer arithmetic, meaning that you pass in an arbitrary chunk of memory instead of anything close to what you wanted.

      Monday, 27-Aug-12 21:02:22 UTC from web
    8. @mostapplethingofall If you want to copy all the bytes one at a time, yeah there is. Just access the string like an array to write a single byte.

      Monday, 27-Aug-12 21:04:07 UTC from web
    9. @mostapplethingofall Yeah, I figured you already knew that first bit, but given how often I see people convinced that "it must be working because it compiles", I thought it was still worth putting out there, despite it not benefiting you specifically. :)

      Monday, 27-Aug-12 21:07:32 UTC from web
    10. @mostapplethingofall Yeah, I don't know any way to do that off the top of my head. Closest way to that would be the solution I just posted, using a pointer.

      Monday, 27-Aug-12 21:08:18 UTC from web
    11. @mostapplethingofall I'm probably overlooking something, but that should technically give the fastest speed. xD

      Monday, 27-Aug-12 21:11:19 UTC from web