Working on long String in C++

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • manishsharma1@gmail.com

    Working on long String in C++

    Hi,

    I have one long String like this:

    015EnvironmentD ata1........

    I want to read first three character from it and convert them to
    integer. This will be the length of the Name of the field and then
    there is value. So if we take above example


    015 means 15 - So we are going to read next 15 Character Starting with
    E of "EnvironmentDat a" till "a".
    Transfer it to come Variable say Field

    Then I have to read the Value of this field which is followed by this
    15 character long Field in the STring that is 1 in the above case.

    I need help in Stripping of the String so that I can get all the
    Fields and their values.

    This has to be in C++. I am new at it. Please help.

    Thanks in advance
  • Victor Bazarov

    #2
    Re: Working on long String in C++

    manishsharma1@g mail.com wrote:
    I have one long String like this:
    >
    015EnvironmentD ata1........
    >
    I want to read first three character from it and convert them to
    integer. This will be the length of the Name of the field and then
    there is value. So if we take above example
    >
    >
    015 means 15 - So we are going to read next 15 Character Starting with
    E of "EnvironmentDat a" till "a".
    Transfer it to come Variable say Field
    >
    Then I have to read the Value of this field which is followed by this
    15 character long Field in the STring that is 1 in the above case.
    >
    I need help in Stripping of the String so that I can get all the
    Fields and their values.
    >
    This has to be in C++. I am new at it. Please help.
    Something like

    std::string const blah("015Enviro nmentData1..... ...");
    int n = -1;
    std::ostringstr eam os(blah.substr( 0, 3));
    os >n;
    std::string Field = blah.substr(3, n);
    os.str() = blah.substr(3 + n, 1);
    int Value = -1;
    os >Value;

    This is untested and only intended to give an idea.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask


    Comment

    • manishsharma1@gmail.com

      #3
      Re: Working on long String in C++

      Hi Victor,

      Thanks for reply.

      This String is coming to the Parsing function in the form of pointer
      to the string. Could you please advice something like the above
      solution that will work with Pointer to String.

      Thanks

      Comment

      • Victor Bazarov

        #4
        Re: Working on long String in C++

        manishsharma1@g mail.com wrote:
        This String is coming to the Parsing function in the form of pointer
        to the string. Could you please advice something like the above
        solution that will work with Pointer to String.
        std::string const blah(Pointer_To _String);

        Everyting else is pretty much the same.

        V
        --
        Please remove capital 'A's when replying by e-mail
        I do not respond to top-posted replies, please don't ask


        Comment

        • manishsharma1@gmail.com

          #5
          Re: Working on long String in C++

          On Jan 28, 3:27 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
          manishshar...@g mail.com wrote:
          This  String is coming to the Parsing function in the form of pointer
          to the string. Could you please advice something like the above
          solution that will work with Pointer to String.
          >
              std::string const blah(Pointer_To _String);
          >
          Everyting else is pretty much the same.
          >
          V
          --
          Please remove capital 'A's when replying by e-mail
          I do not respond to top-posted replies, please don't ask
          Hi Victor,

          My code is Unicode and I have to use CstString. Please suggest some
          solution related to that.

          Thanks

          Comment

          • peter koch

            #6
            Re: Working on long String in C++

            On 30 Jan., 23:22, manishshar...@g mail.com wrote:
            On Jan 28, 3:27 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
            >
            manishshar...@g mail.com wrote:
            This  String is coming to the Parsing function in the form of pointer
            to the string. Could you please advice something like the above
            solution that will work with Pointer to String.
            >
                std::string const blah(Pointer_To _String);
            >
            Everyting else is pretty much the same.
            >
            V
            --
            Please remove capital 'A's when replying by e-mail
            I do not respond to top-posted replies, please don't ask
            >
            Hi Victor,
            >
            My code is Unicode and I have to use CstString. Please suggest some
            solution related to that.
            >
            Ask somewhere where CstString is topical. This is not the place.

            /Peter

            Comment

            • manishsharma1@gmail.com

              #7
              Re: Working on long String in C++

              I meant CStdString

              Comment

              • Richard Herring

                #8
                Re: Working on long String in C++

                In message
                <ee6e9bf2-e744-4f50-9db3-36b124783f04@k2 g2000hse.google groups.com>,
                manishsharma1@g mail.com writes

                [please quote some context in your posts]
                >I meant CStdString
                >
                Same answer.
                --
                Richard Herring

                Comment

                • manishsharma1@gmail.com

                  #9
                  Re: Working on long String in C++

                  Can you suggest where to post it then. I am new to development world.

                  Thanks in Advance

                  Comment

                  • peter koch

                    #10
                    Re: Working on long String in C++

                    On 31 Jan., 16:37, manishshar...@g mail.com wrote:
                    Can you suggest where to post it then. I am new to development world.
                    >
                    Thanks in Advance
                    Hello

                    I am afraid I don't know. I suppose you know the name of the library/
                    development environment you use? In that case it should be a matter of
                    minutes before googling e.g. google newsgroups should provide you with
                    the name of an appropriate newsgroup.

                    /Peter

                    Comment

                    • manishsharma1@gmail.com

                      #11
                      Re: Working on long String in C++

                      On Jan 31, 10:45 am, peter koch <peter.koch.lar ...@gmail.comwr ote:
                      On 31 Jan., 16:37, manishshar...@g mail.com wrote:
                      >
                      Can you suggest where to post it then. I am new to development world.
                      >
                      Thanks in Advance
                      >
                      Hello
                      >
                      I am afraid I don't know. I suppose you know the name of the library/
                      development environment you use? In that case it should be a matter of
                      minutes before googling e.g. google newsgroups should provide you with
                      the name of an appropriate newsgroup.
                      >
                      /Peter
                      Thanks.

                      Comment

                      • Hans Mull

                        #12
                        Re: Working on long String in C++

                        manishsharma1@g mail.com schrieb:
                        On Jan 31, 10:45 am, peter koch <peter.koch.lar ...@gmail.comwr ote:
                        >On 31 Jan., 16:37, manishshar...@g mail.com wrote:
                        >>
                        >>Can you suggest where to post it then. I am new to development world.
                        >>Thanks in Advance
                        >Hello
                        >>
                        >I am afraid I don't know. I suppose you know the name of the library/
                        >development environment you use? In that case it should be a matter of
                        >minutes before googling e.g. google newsgroups should provide you with
                        >the name of an appropriate newsgroup.
                        >>
                        >/Peter
                        >
                        Thanks.
                        Are you German?
                        If yes, try
                        Deutsprachige C++ Community - Irgendwer hat immer eine Antwort


                        Kind regards

                        Comment

                        • Richard Herring

                          #13
                          Re: Working on long String in C++

                          In message <fnsspq$d3b$1@o nline.de>, Hans Mull
                          <deyringer@goog lemail.comwrite s
                          >manishsharma1@ gmail.com schrieb:
                          >On Jan 31, 10:45 am, peter koch <peter.koch.lar ...@gmail.comwr ote:
                          >>On 31 Jan., 16:37, manishshar...@g mail.com wrote:
                          >>>
                          >>>Can you suggest where to post it then. I am new to development world.
                          >>>Thanks in Advance
                          >>Hello
                          >>>
                          >>I am afraid I don't know. I suppose you know the name of the library/
                          >>development environment you use? In that case it should be a matter of
                          >>minutes before googling e.g. google newsgroups should provide you with
                          >>the name of an appropriate newsgroup.
                          >>
                          >Thanks.
                          >Are you German?
                          >If yes, try
                          >http://www.c-plusplus.de/forum/
                          Does the German C++ standard define a type called CStdString, or are
                          they just more tolerant of off-topicality there?

                          --
                          Richard Herring

                          Comment

                          Working...