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. ATL / WTL / STL
  4. beginner stl basic_string question

beginner stl basic_string question

Scheduled Pinned Locked Moved ATL / WTL / STL
questionc++tutoriallearning
5 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.
  • M Offline
    M Offline
    mweiss
    wrote on last edited by
    #1

    i'm using the copy method of the basic_string. i'm a little confused about the first parameter. could someone please post a simple example of copying from one basic_string to another? thanks melinda

    J 1 Reply Last reply
    0
    • M mweiss

      i'm using the copy method of the basic_string. i'm a little confused about the first parameter. could someone please post a simple example of copying from one basic_string to another? thanks melinda

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      std::string str="hello heaven";

      char buffer[1000];
      str.copy(buffer,4); // copies "hell" without any terminating null character

      Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      M 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        std::string str="hello heaven";

        char buffer[1000];
        str.copy(buffer,4); // copies "hell" without any terminating null character

        Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        M Offline
        M Offline
        mweiss
        wrote on last edited by
        #3

        would it work the same way if i were copying from one basic_string to another basic_string? in that case i'm not actually using the string. melinda

        J 1 Reply Last reply
        0
        • M mweiss

          would it work the same way if i were copying from one basic_string to another basic_string? in that case i'm not actually using the string. melinda

          J Offline
          J Offline
          Joaquin M Lopez Munoz
          wrote on last edited by
          #4

          Er, I do not understand completely your question. copy will work the same for basic_string<TCHAR>s, except that what it copies are TCHARs instead of chars. copy does ont have anything to do with copying from one basic_string to another. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

          M 1 Reply Last reply
          0
          • J Joaquin M Lopez Munoz

            Er, I do not understand completely your question. copy will work the same for basic_string<TCHAR>s, except that what it copies are TCHARs instead of chars. copy does ont have anything to do with copying from one basic_string to another. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

            M Offline
            M Offline
            mweiss
            wrote on last edited by
            #5

            thanks...i get it now :)

            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