Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Where I can learn about using wsprintf?

Where I can learn about using wsprintf?

Scheduled Pinned Locked Moved C / C++ / MFC
csharpvisual-studiotutorialquestionannouncement
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GESY
    wrote on last edited by
    #1

    Where I can learn about using wsprintf? I using Visual Studio 12 with plain C Code Lines. For examples, this lines give me 2 different results depending on the formatting I believe but I can't find any practical info about it. For example what the " >>6" or " >>12" do? Thanks, check the code below and you see what I mean DWORD DVALE=19542016; wsprintf(BUFF, "Version is %d \n Good Night",DVALE >>6 & 0xff); MessageBox(hWndMain,BUFF,"The Value",MB_OK); // Display 192 wsprintf(BUFF, "Version is %d \n Good Night",DVALE >> 12 & 0xff); MessageBox(hWndMain,BUFF,"The Value",MB_OK); // Display 163

    V J L 3 Replies Last reply
    0
    • G GESY

      Where I can learn about using wsprintf? I using Visual Studio 12 with plain C Code Lines. For examples, this lines give me 2 different results depending on the formatting I believe but I can't find any practical info about it. For example what the " >>6" or " >>12" do? Thanks, check the code below and you see what I mean DWORD DVALE=19542016; wsprintf(BUFF, "Version is %d \n Good Night",DVALE >>6 & 0xff); MessageBox(hWndMain,BUFF,"The Value",MB_OK); // Display 192 wsprintf(BUFF, "Version is %d \n Good Night",DVALE >> 12 & 0xff); MessageBox(hWndMain,BUFF,"The Value",MB_OK); // Display 163

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      1. Did you try to pass the L"Version is %d \n Good Night" rather than "Version is %d \n Good Night"? 2. " >>6" or " >>12" just do what they must do according to the https://msdn.microsoft.com/en-us/library/336xbhcz.aspx?f=255&MSPPError=-2147217396

      1 Reply Last reply
      0
      • G GESY

        Where I can learn about using wsprintf? I using Visual Studio 12 with plain C Code Lines. For examples, this lines give me 2 different results depending on the formatting I believe but I can't find any practical info about it. For example what the " >>6" or " >>12" do? Thanks, check the code below and you see what I mean DWORD DVALE=19542016; wsprintf(BUFF, "Version is %d \n Good Night",DVALE >>6 & 0xff); MessageBox(hWndMain,BUFF,"The Value",MB_OK); // Display 192 wsprintf(BUFF, "Version is %d \n Good Night",DVALE >> 12 & 0xff); MessageBox(hWndMain,BUFF,"The Value",MB_OK); // Display 163

        J Offline
        J Offline
        Joe Woodbury
        wrote on last edited by
        #3

        The greater-than signs are shift operators (https://msdn.microsoft.com/en-us/library/336xbhcz.aspx?f=255&MSPPError=-2147217396). The result is then truncated using a bitwise and operator (Bitwise AND Operator: &[^])

        G 2 Replies Last reply
        0
        • J Joe Woodbury

          The greater-than signs are shift operators (https://msdn.microsoft.com/en-us/library/336xbhcz.aspx?f=255&MSPPError=-2147217396). The result is then truncated using a bitwise and operator (Bitwise AND Operator: &[^])

          G Offline
          G Offline
          GESY
          wrote on last edited by
          #4

          Auch, you think I can remember those days? That's a lot of math, if I start experimenting I may get it back. But for now, that page got me hungry!!! But I did catch the idea of shifting, all this because a code that I posted here, that some one tested and said works correctly and got the right values, however I don't, I do not see how may code works correctly on his computer, but on mine I get big numbers, far for what I am looking for. Go ahead and check it, and tell me what you think if you please.... Thanks Look for "No-Errors-but-wrong-values-on-return"

          J 1 Reply Last reply
          0
          • G GESY

            Auch, you think I can remember those days? That's a lot of math, if I start experimenting I may get it back. But for now, that page got me hungry!!! But I did catch the idea of shifting, all this because a code that I posted here, that some one tested and said works correctly and got the right values, however I don't, I do not see how may code works correctly on his computer, but on mine I get big numbers, far for what I am looking for. Go ahead and check it, and tell me what you think if you please.... Thanks Look for "No-Errors-but-wrong-values-on-return"

            J Offline
            J Offline
            Joe Woodbury
            wrote on last edited by
            #5

            Sorry, I can't diagnose what happens on your computer. (And whatever you are doing elsewhere is pointless and bad practice. Errors in your code have been identified. Just check the windows version and end it there. To clarify: DON'T check the versions of system DLLs. There are multiple versions of many DLLs and you have no idea which DLL is actually being used.)

            G 1 Reply Last reply
            0
            • G GESY

              Where I can learn about using wsprintf? I using Visual Studio 12 with plain C Code Lines. For examples, this lines give me 2 different results depending on the formatting I believe but I can't find any practical info about it. For example what the " >>6" or " >>12" do? Thanks, check the code below and you see what I mean DWORD DVALE=19542016; wsprintf(BUFF, "Version is %d \n Good Night",DVALE >>6 & 0xff); MessageBox(hWndMain,BUFF,"The Value",MB_OK); // Display 192 wsprintf(BUFF, "Version is %d \n Good Night",DVALE >> 12 & 0xff); MessageBox(hWndMain,BUFF,"The Value",MB_OK); // Display 163

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              wsprintf is not the issue, it is how you are extracting the numbers from the version structure. Check the version documentation again.

              1 Reply Last reply
              0
              • J Joe Woodbury

                Sorry, I can't diagnose what happens on your computer. (And whatever you are doing elsewhere is pointless and bad practice. Errors in your code have been identified. Just check the windows version and end it there. To clarify: DON'T check the versions of system DLLs. There are multiple versions of many DLLs and you have no idea which DLL is actually being used.)

                G Offline
                G Offline
                GESY
                wrote on last edited by
                #7

                But you can tell the studio whichone too look for or use, I think.

                1 Reply Last reply
                0
                • J Joe Woodbury

                  The greater-than signs are shift operators (https://msdn.microsoft.com/en-us/library/336xbhcz.aspx?f=255&MSPPError=-2147217396). The result is then truncated using a bitwise and operator (Bitwise AND Operator: &[^])

                  G Offline
                  G Offline
                  GESY
                  wrote on last edited by
                  #8

                  Thank you very much I got the idea now, 100000 of thanks.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups