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. Managed C++/CLI
  4. type convert problem

type convert problem

Scheduled Pinned Locked Moved Managed C++/CLI
helptutorialquestion
3 Posts 3 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.
  • B Offline
    B Offline
    bloodwinner
    wrote on last edited by
    #1

    string strd1 = "9"; int m=atoi(strd); Got the error: error C2664: 'atoi' : cannot convert parameter 1 from 'class std::basic_string,class std::allocator >' to 'const char *' how to change the second line to make it work?

    G J 2 Replies Last reply
    0
    • B bloodwinner

      string strd1 = "9"; int m=atoi(strd); Got the error: error C2664: 'atoi' : cannot convert parameter 1 from 'class std::basic_string,class std::allocator >' to 'const char *' how to change the second line to make it work?

      G Offline
      G Offline
      George L Jackson
      wrote on last edited by
      #2

      This is the correct way: string strd1 = "9"; int m = atoi(strd1.c_str());

      1 Reply Last reply
      0
      • B bloodwinner

        string strd1 = "9"; int m=atoi(strd); Got the error: error C2664: 'atoi' : cannot convert parameter 1 from 'class std::basic_string,class std::allocator >' to 'const char *' how to change the second line to make it work?

        J Offline
        J Offline
        jocblack
        wrote on last edited by
        #3

        I have the same problem long time ago. It is a mix mode of string vs char. Here the solution: define string strd1 = "9"; as char strd1 [1]="9"; or CString strd1 ="9";

        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