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. Help

Help

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorial
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.
  • R Offline
    R Offline
    Rylogy
    wrote on last edited by
    #1

    :confused:Hi i'm having difficulties, kinda fresh in C++ and I want to know how to do this code in C++: "Dim name As String" anyone tell me how to do it in C++ please

    G A 2 Replies Last reply
    0
    • R Rylogy

      :confused:Hi i'm having difficulties, kinda fresh in C++ and I want to know how to do this code in C++: "Dim name As String" anyone tell me how to do it in C++ please

      G Offline
      G Offline
      Gary R Wheeler
      wrote on last edited by
      #2

      The answer is: it depends. In simplest 'C' terms (which also works for C++), strings are arrays of characters:

      char str[128];
      strcpy(str,"This is a string");

      defines a string str. Strings are terminated by a 0 byte, which marks the end of the string. In order to set the string, or assign one string to another, you have to call a function like strcpy. If you are using Microsoft Visual C++ and the MFC (Microsoft Foundation Class) library, you've got a class called CString:

      CString str;
      str = "This is a string";

      CString makes using strings a lot easier than the 'array of characters' approach. Instead of having to call functions to do simple operations like assigning one string to another, you can use a simple assignment:

      CString str1("This is string 1");
      CString str2("This is string 2");
      str1 = str2;

      CString also defines the '+' operator for doing string concatenation, along with others. The Standard Template Library (STL) defines a string class as well. I'm not familiar with the STL, but you should be able to find examples.


      Software Zen: delete this;

      1 Reply Last reply
      0
      • R Rylogy

        :confused:Hi i'm having difficulties, kinda fresh in C++ and I want to know how to do this code in C++: "Dim name As String" anyone tell me how to do it in C++ please

        A Offline
        A Offline
        Alexander M
        wrote on last edited by
        #3

        Read tutorials.... Don't try it, just do it! ;-)

        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