declaring cin.getline() vs getline()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yana
    New Member
    • Mar 2007
    • 12

    declaring cin.getline() vs getline()

    what is the difference between the cin.getline() function and getline() function?
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by yana
    What is the difference between the cin.getline() function and getline() function?
    In one you explicitly declare the cin stream.

    Comment

    • RedSon
      Recognized Expert Expert
      • Jan 2007
      • 4980

      #3
      Nothing except one version you explicitly call it on the cin stream whereas the other is implicit.

      Comment

      • yana
        New Member
        • Mar 2007
        • 12

        #4
        Can you initialize C++ string from C-string? and
        Can you initialize C-string from C++ string?

        Comment

        • sicarie
          Recognized Expert Specialist
          • Nov 2006
          • 4677

          #5
          Originally posted by yana
          Can you initialize C++ string from C-string? and
          Can you initialize C-string from C++ string?
          I have merged these threads, and changed the title to better explain the problem

          Comment

          • Ganon11
            Recognized Expert Specialist
            • Oct 2006
            • 3651

            #6
            I'm pretty sure you can create a C++ string (std::string) using a cstring as its parameter - something like:

            Code:
            char mycstr[20] = "Hello Guys!\0";
            std::string mystr(mycstr);
            As for making a cstring from an std::string, there may be a function within std::string to return the character array, or you could simply create your own by iterating through the characters of the string and assigning them to an element in a cstring.

            Comment

            • lqdeffx
              New Member
              • Mar 2007
              • 39

              #7
              this function will only work copying to a char*, NOT to a string data type
              Code:
              strcpy(char* destination,const char* source)

              Comment

              Working...