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. char -> string.append problem

char -> string.append problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++javascriptjsonlearning
4 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.
  • S Offline
    S Offline
    Scozturk
    wrote on last edited by
    #1

    Hi! I am using the win32 api c++. I have a problem when I try to get some variables from textboxes and comboboxes. string code; char getvalues; code.append("your values are: "); GetDlgItemText(hwnd, IDC_E1, &getvalues,20); code.append(&getvalues); code.append(" from e1- "); GetDlgItemText(hwnd, IDC_E2, &getvalues,20); code.append(&getvalues); code.append(" from e2- "); ..... Well this code works fine if there are no spaces or special characters between the values in the boxes but when there is a value like "text-decoration" or "text decoration" it gives an error. The error comes when the code.append(&getvalue) is processed. I want to use the code in a javascript generation application. Thank you very much for your answers in advance! Well... I am a beginner ...

    P V R 3 Replies Last reply
    0
    • S Scozturk

      Hi! I am using the win32 api c++. I have a problem when I try to get some variables from textboxes and comboboxes. string code; char getvalues; code.append("your values are: "); GetDlgItemText(hwnd, IDC_E1, &getvalues,20); code.append(&getvalues); code.append(" from e1- "); GetDlgItemText(hwnd, IDC_E2, &getvalues,20); code.append(&getvalues); code.append(" from e2- "); ..... Well this code works fine if there are no spaces or special characters between the values in the boxes but when there is a value like "text-decoration" or "text decoration" it gives an error. The error comes when the code.append(&getvalue) is processed. I want to use the code in a javascript generation application. Thank you very much for your answers in advance! Well... I am a beginner ...

      P Offline
      P Offline
      palbano
      wrote on last edited by
      #2

      getvalues is a type char and you are telling GetDlgItemText that it is 20 bytes long. It's not so you will get undesirable behavior.

      "No matter where you go, there your are." - Buckaroo Banzai

      -pete

      1 Reply Last reply
      0
      • S Scozturk

        Hi! I am using the win32 api c++. I have a problem when I try to get some variables from textboxes and comboboxes. string code; char getvalues; code.append("your values are: "); GetDlgItemText(hwnd, IDC_E1, &getvalues,20); code.append(&getvalues); code.append(" from e1- "); GetDlgItemText(hwnd, IDC_E2, &getvalues,20); code.append(&getvalues); code.append(" from e2- "); ..... Well this code works fine if there are no spaces or special characters between the values in the boxes but when there is a value like "text-decoration" or "text decoration" it gives an error. The error comes when the code.append(&getvalue) is processed. I want to use the code in a javascript generation application. Thank you very much for your answers in advance! Well... I am a beginner ...

        V Offline
        V Offline
        V 0
        wrote on last edited by
        #3

        get CWnd object of your control GetWindowText(ACString); that's easier. I'm not sure but can you add more then 1 char to something defined as char somename? (better char* somename) maybe thats your mistake? I would go for the first try. CStrings are for once really managable. Good luck. "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

        1 Reply Last reply
        0
        • S Scozturk

          Hi! I am using the win32 api c++. I have a problem when I try to get some variables from textboxes and comboboxes. string code; char getvalues; code.append("your values are: "); GetDlgItemText(hwnd, IDC_E1, &getvalues,20); code.append(&getvalues); code.append(" from e1- "); GetDlgItemText(hwnd, IDC_E2, &getvalues,20); code.append(&getvalues); code.append(" from e2- "); ..... Well this code works fine if there are no spaces or special characters between the values in the boxes but when there is a value like "text-decoration" or "text decoration" it gives an error. The error comes when the code.append(&getvalue) is processed. I want to use the code in a javascript generation application. Thank you very much for your answers in advance! Well... I am a beginner ...

          R Offline
          R Offline
          RChin
          wrote on last edited by
          #4

          Scolinks wrote: string code; char getvalues; shouldn't this be : string code; **char getvalues[20+1]** ?


          I Dream of Absolute Zero

          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