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. whats wrong witt this?

whats wrong witt this?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
6 Posts 2 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
    SilverShalkin
    wrote on last edited by
    #1

    ok... my problem accures in this line of code: strcpy(M_ID, STID); error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *' M_ID is a member of my class ID, and STID is a char created within the function that this code lies. i dont understand why it says char to * char because, non of them are pointers. thanks for your help! ~SilverShalkin

    P 1 Reply Last reply
    0
    • S SilverShalkin

      ok... my problem accures in this line of code: strcpy(M_ID, STID); error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *' M_ID is a member of my class ID, and STID is a char created within the function that this code lies. i dont understand why it says char to * char because, non of them are pointers. thanks for your help! ~SilverShalkin

      P Offline
      P Offline
      Paul M Watt
      wrote on last edited by
      #2

      strcpy requires char* as arguements to the function. So if STID is a plain char, the compiler will attempt to convert the char to a char* to fit into the arguement in strcpy. Since there is no conversion for the compiler to do this, it reports and error. You will need to use a char*.


      Build a man a fire, and he will be warm for a day
      Light a man on fire, and he will be warm for the rest of his life!

      S 1 Reply Last reply
      0
      • P Paul M Watt

        strcpy requires char* as arguements to the function. So if STID is a plain char, the compiler will attempt to convert the char to a char* to fit into the arguement in strcpy. Since there is no conversion for the compiler to do this, it reports and error. You will need to use a char*.


        Build a man a fire, and he will be warm for a day
        Light a man on fire, and he will be warm for the rest of his life!

        S Offline
        S Offline
        SilverShalkin
        wrote on last edited by
        #3

        ok... so i would have to have a pointer on the second one like: strcpy(M_ID, *PID); *PID points to SID which is the intake of info for the function. or would i do... strcpy(M_ID, PID); //without derefrencing it? Thanks! ~SilverShalkin :rose:

        P 1 Reply Last reply
        0
        • S SilverShalkin

          ok... so i would have to have a pointer on the second one like: strcpy(M_ID, *PID); *PID points to SID which is the intake of info for the function. or would i do... strcpy(M_ID, PID); //without derefrencing it? Thanks! ~SilverShalkin :rose:

          P Offline
          P Offline
          Paul M Watt
          wrote on last edited by
          #4

          You do not want to dereference it. But once again, PID must be a char*.


          Build a man a fire, and he will be warm for a day
          Light a man on fire, and he will be warm for the rest of his life!

          S 1 Reply Last reply
          0
          • P Paul M Watt

            You do not want to dereference it. But once again, PID must be a char*.


            Build a man a fire, and he will be warm for a day
            Light a man on fire, and he will be warm for the rest of his life!

            S Offline
            S Offline
            SilverShalkin
            wrote on last edited by
            #5

            i changed it to what you said, and now i got this error pop up: error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *' what does it mean by parameter 1? thanks! ~SilverShalkin :rose:

            S 1 Reply Last reply
            0
            • S SilverShalkin

              i changed it to what you said, and now i got this error pop up: error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *' what does it mean by parameter 1? thanks! ~SilverShalkin :rose:

              S Offline
              S Offline
              SilverShalkin
              wrote on last edited by
              #6

              well, i looked up some of my errors in msdn and it said that the main problem of the code is that the person is trying to set two seperate things equal to each other, like-a pointer and a non pointer, or a intiger and a character. one of the main problems as i was going through out figuering this out was... my header file held different info than my cpp, so it made a bunch on errors.... I think i got it, to the point that i wont come across the problem again, unless its a typo "which, as a experienced programmer know (theres always typos :) )" Thanks for your help! ~SilverShalkin :rose:

              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