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. convert short to Cstring...

convert short to Cstring...

Scheduled Pinned Locked Moved C / C++ / MFC
databasetutorialquestion
5 Posts 5 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.
  • S Offline
    S Offline
    spalanivel
    wrote on last edited by
    #1

    Hi, short m_start_year; COleDateTime tm = COleDateTime::GetCurrentTime(); m_start_year = (short) tm.GetYear(); I need to convert this m_start_year to CString to pass a argument for below function. CString result_startdate = GetShowYear(m_start_year); CString GetShowYear(CString m_start_year) { // Here i will do the Inline query and get the show start date. } In the above code how to cast short to CString as the GetShowYear need to pass only CString value but from tm.GetYear() i am getting as "short" value. Any idea? Reg, SPa

    V L C 3 Replies Last reply
    0
    • S spalanivel

      Hi, short m_start_year; COleDateTime tm = COleDateTime::GetCurrentTime(); m_start_year = (short) tm.GetYear(); I need to convert this m_start_year to CString to pass a argument for below function. CString result_startdate = GetShowYear(m_start_year); CString GetShowYear(CString m_start_year) { // Here i will do the Inline query and get the show start date. } In the above code how to cast short to CString as the GetShowYear need to pass only CString value but from tm.GetYear() i am getting as "short" value. Any idea? Reg, SPa

      V Offline
      V Offline
      venkatmakam
      wrote on last edited by
      #2

      Use CString::Format funcion to convert short to string like this.

      CString strYear;
      strYear.Format("%d", m_start_year);

      http://www.mono-project.com/Main\_Page

      A 1 Reply Last reply
      0
      • S spalanivel

        Hi, short m_start_year; COleDateTime tm = COleDateTime::GetCurrentTime(); m_start_year = (short) tm.GetYear(); I need to convert this m_start_year to CString to pass a argument for below function. CString result_startdate = GetShowYear(m_start_year); CString GetShowYear(CString m_start_year) { // Here i will do the Inline query and get the show start date. } In the above code how to cast short to CString as the GetShowYear need to pass only CString value but from tm.GetYear() i am getting as "short" value. Any idea? Reg, SPa

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

        You cannot cast a short to a string, you need to use a converter such as sprintf() or similar.

        The best things in life are not things.

        1 Reply Last reply
        0
        • V venkatmakam

          Use CString::Format funcion to convert short to string like this.

          CString strYear;
          strYear.Format("%d", m_start_year);

          http://www.mono-project.com/Main\_Page

          A Offline
          A Offline
          Albert Holguin
          wrote on last edited by
          #4

          Simple yet very effective. :thumbsup:

          1 Reply Last reply
          0
          • S spalanivel

            Hi, short m_start_year; COleDateTime tm = COleDateTime::GetCurrentTime(); m_start_year = (short) tm.GetYear(); I need to convert this m_start_year to CString to pass a argument for below function. CString result_startdate = GetShowYear(m_start_year); CString GetShowYear(CString m_start_year) { // Here i will do the Inline query and get the show start date. } In the above code how to cast short to CString as the GetShowYear need to pass only CString value but from tm.GetYear() i am getting as "short" value. Any idea? Reg, SPa

            C Offline
            C Offline
            Cool_Dev
            wrote on last edited by
            #5

            In addition, _itoa() and similar functions are also there.

            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