While extracting character from a string in C++, why do I have to do this?












4















string s; string adder;
for (int i = s.size ()-1; i >= 0; i--) {
adder += s[i];
}
cout << adder << endl;


I am trying to reverse a string using c++ and am confused why do we have to do s.size()-1 and why does it print a space when we don't have -1?










share|improve this question




















  • 5





    Array indexes reside in [0, s.size()). s[s.size()] is one past the end of the array so you need to start at s.size()-1.

    – 0x499602D2
    Nov 21 '18 at 14:13











  • @0x499602D2 - That's an answer. So, you know...

    – StoryTeller
    Nov 21 '18 at 14:16













  • Possible duplicate of Why does the indexing start with zero in 'C'?

    – dandan78
    Nov 23 '18 at 13:45
















4















string s; string adder;
for (int i = s.size ()-1; i >= 0; i--) {
adder += s[i];
}
cout << adder << endl;


I am trying to reverse a string using c++ and am confused why do we have to do s.size()-1 and why does it print a space when we don't have -1?










share|improve this question




















  • 5





    Array indexes reside in [0, s.size()). s[s.size()] is one past the end of the array so you need to start at s.size()-1.

    – 0x499602D2
    Nov 21 '18 at 14:13











  • @0x499602D2 - That's an answer. So, you know...

    – StoryTeller
    Nov 21 '18 at 14:16













  • Possible duplicate of Why does the indexing start with zero in 'C'?

    – dandan78
    Nov 23 '18 at 13:45














4












4








4








string s; string adder;
for (int i = s.size ()-1; i >= 0; i--) {
adder += s[i];
}
cout << adder << endl;


I am trying to reverse a string using c++ and am confused why do we have to do s.size()-1 and why does it print a space when we don't have -1?










share|improve this question
















string s; string adder;
for (int i = s.size ()-1; i >= 0; i--) {
adder += s[i];
}
cout << adder << endl;


I am trying to reverse a string using c++ and am confused why do we have to do s.size()-1 and why does it print a space when we don't have -1?







c++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 14:20









PC Luddite

4,71051536




4,71051536










asked Nov 21 '18 at 14:11







user10655470















  • 5





    Array indexes reside in [0, s.size()). s[s.size()] is one past the end of the array so you need to start at s.size()-1.

    – 0x499602D2
    Nov 21 '18 at 14:13











  • @0x499602D2 - That's an answer. So, you know...

    – StoryTeller
    Nov 21 '18 at 14:16













  • Possible duplicate of Why does the indexing start with zero in 'C'?

    – dandan78
    Nov 23 '18 at 13:45














  • 5





    Array indexes reside in [0, s.size()). s[s.size()] is one past the end of the array so you need to start at s.size()-1.

    – 0x499602D2
    Nov 21 '18 at 14:13











  • @0x499602D2 - That's an answer. So, you know...

    – StoryTeller
    Nov 21 '18 at 14:16













  • Possible duplicate of Why does the indexing start with zero in 'C'?

    – dandan78
    Nov 23 '18 at 13:45








5




5





Array indexes reside in [0, s.size()). s[s.size()] is one past the end of the array so you need to start at s.size()-1.

– 0x499602D2
Nov 21 '18 at 14:13





Array indexes reside in [0, s.size()). s[s.size()] is one past the end of the array so you need to start at s.size()-1.

– 0x499602D2
Nov 21 '18 at 14:13













@0x499602D2 - That's an answer. So, you know...

– StoryTeller
Nov 21 '18 at 14:16







@0x499602D2 - That's an answer. So, you know...

– StoryTeller
Nov 21 '18 at 14:16















Possible duplicate of Why does the indexing start with zero in 'C'?

– dandan78
Nov 23 '18 at 13:45





Possible duplicate of Why does the indexing start with zero in 'C'?

– dandan78
Nov 23 '18 at 13:45












3 Answers
3






active

oldest

votes


















4














Array indexes reside in [0, s.size()). s[s.size()] is one past the end of the array so you need to start at s.size()-1.



You can see that this is needed if you use the at() member function which uses bounds checking:



adder += s.at(i); // throws exception if i is out of bounds





share|improve this answer

































    1














    In you code s is a string variable that holds some characters. And as you said you want to display its contents in reverse order.



    In order to do that, you have to navigate through the contents of s from back to front. To do that, as shown in your code you used for-loop.



    Let's say s contains 10 characters. Since you are accessing your string s back-to-front, the last character found at the 10 - 1 = 9th index, because it starts counting from 0, not 1.



    EDIT with Example



    string original = "Hello";
    string reverse;
    for (int i = original.size() - 1; i >= 0; i--) {
    reverse += original[i];
    }
    cout << reverse << endl;


    As you can see in the above example, original is a string variable which holds five characters, and reverse is also a string variable which is about to hold the contents of original in reverse order. In order to reverse the contents of original, we must navigate through it back-to-front.



    original[4] = o
    original[3] = l
    original[2] = l
    original[1] = e
    original[0] = H


    The above characters will be added one by one at each iteration of the for-loop as shown below:



    reverse = "";  //it was empty first
    reverse = reverse + original[4]; // now it holds the last character -> o
    reverse = reverse + original[3]; // now it holds the characters -> ol
    reverse = reverse + original[2]; // now it holds the characters -> oll
    reverse = reverse + original[1]; // now it holds the characters -> olle
    reverse = reverse + original[0]; // now it holds the characters -> olleh





    share|improve this answer


























    • While allocating an array let's say int array[5]. So this array can store 6 elements then?

      – user10655470
      Nov 21 '18 at 19:04











    • @CyborgGamer No it stores 5 elements, and the indexes go from 0 to 4.

      – 0x499602D2
      Nov 21 '18 at 22:33











    • @CyborgGamer No it is not. The confusion will banish once you are more familiar with arrays. Array of size 5 will contains only 5 elements (array[0], array[1], array[2], array[3] and array[4]).

      – Hello World
      Nov 22 '18 at 10:37











    • Hello guys, I am really rusty on arrays. Especially in C. How can I improve my knowledge on array?

      – user10655470
      Nov 23 '18 at 11:04






    • 1





      @CyborgGamer you should try to understand arrays from the scratch. Just ignore using your question as an example. If an array has size of 6, then it will always contain 6 items in it. But instead of accessing the last item using array[6], we will use array[5], because the counting starts from array[0] instead of array[1]. array[0] hold the first item, array[1] the second, ... and array[5] the sixth. It is simple as that.

      – Hello World
      Dec 3 '18 at 5:58



















    0














    It is because indexing is zero-based. So the first element is at position zero.



    Since you use c++ you may (and should) use reverse iterators:



    for (auto it = str.rbegin(); it != str.rend(); ++it) {
    char& c = *it;
    //do stuff
    }


    If you have boost you can just do:



    for (auto c : boost::adaptors::reversed(str)) {
    }





    share|improve this answer


























    • How does this answer the OP? And how does it help OP understand zero-based indexes?

      – Jim Rhodes
      Nov 21 '18 at 14:23











    • Yup, this should be a comment.

      – HolyBlackCat
      Nov 21 '18 at 14:24











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53413962%2fwhile-extracting-character-from-a-string-in-c-why-do-i-have-to-do-this%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown
























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    Array indexes reside in [0, s.size()). s[s.size()] is one past the end of the array so you need to start at s.size()-1.



    You can see that this is needed if you use the at() member function which uses bounds checking:



    adder += s.at(i); // throws exception if i is out of bounds





    share|improve this answer






























      4














      Array indexes reside in [0, s.size()). s[s.size()] is one past the end of the array so you need to start at s.size()-1.



      You can see that this is needed if you use the at() member function which uses bounds checking:



      adder += s.at(i); // throws exception if i is out of bounds





      share|improve this answer




























        4












        4








        4







        Array indexes reside in [0, s.size()). s[s.size()] is one past the end of the array so you need to start at s.size()-1.



        You can see that this is needed if you use the at() member function which uses bounds checking:



        adder += s.at(i); // throws exception if i is out of bounds





        share|improve this answer















        Array indexes reside in [0, s.size()). s[s.size()] is one past the end of the array so you need to start at s.size()-1.



        You can see that this is needed if you use the at() member function which uses bounds checking:



        adder += s.at(i); // throws exception if i is out of bounds






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 21 '18 at 14:23

























        answered Nov 21 '18 at 14:16









        0x499602D20x499602D2

        68.1k26120207




        68.1k26120207

























            1














            In you code s is a string variable that holds some characters. And as you said you want to display its contents in reverse order.



            In order to do that, you have to navigate through the contents of s from back to front. To do that, as shown in your code you used for-loop.



            Let's say s contains 10 characters. Since you are accessing your string s back-to-front, the last character found at the 10 - 1 = 9th index, because it starts counting from 0, not 1.



            EDIT with Example



            string original = "Hello";
            string reverse;
            for (int i = original.size() - 1; i >= 0; i--) {
            reverse += original[i];
            }
            cout << reverse << endl;


            As you can see in the above example, original is a string variable which holds five characters, and reverse is also a string variable which is about to hold the contents of original in reverse order. In order to reverse the contents of original, we must navigate through it back-to-front.



            original[4] = o
            original[3] = l
            original[2] = l
            original[1] = e
            original[0] = H


            The above characters will be added one by one at each iteration of the for-loop as shown below:



            reverse = "";  //it was empty first
            reverse = reverse + original[4]; // now it holds the last character -> o
            reverse = reverse + original[3]; // now it holds the characters -> ol
            reverse = reverse + original[2]; // now it holds the characters -> oll
            reverse = reverse + original[1]; // now it holds the characters -> olle
            reverse = reverse + original[0]; // now it holds the characters -> olleh





            share|improve this answer


























            • While allocating an array let's say int array[5]. So this array can store 6 elements then?

              – user10655470
              Nov 21 '18 at 19:04











            • @CyborgGamer No it stores 5 elements, and the indexes go from 0 to 4.

              – 0x499602D2
              Nov 21 '18 at 22:33











            • @CyborgGamer No it is not. The confusion will banish once you are more familiar with arrays. Array of size 5 will contains only 5 elements (array[0], array[1], array[2], array[3] and array[4]).

              – Hello World
              Nov 22 '18 at 10:37











            • Hello guys, I am really rusty on arrays. Especially in C. How can I improve my knowledge on array?

              – user10655470
              Nov 23 '18 at 11:04






            • 1





              @CyborgGamer you should try to understand arrays from the scratch. Just ignore using your question as an example. If an array has size of 6, then it will always contain 6 items in it. But instead of accessing the last item using array[6], we will use array[5], because the counting starts from array[0] instead of array[1]. array[0] hold the first item, array[1] the second, ... and array[5] the sixth. It is simple as that.

              – Hello World
              Dec 3 '18 at 5:58
















            1














            In you code s is a string variable that holds some characters. And as you said you want to display its contents in reverse order.



            In order to do that, you have to navigate through the contents of s from back to front. To do that, as shown in your code you used for-loop.



            Let's say s contains 10 characters. Since you are accessing your string s back-to-front, the last character found at the 10 - 1 = 9th index, because it starts counting from 0, not 1.



            EDIT with Example



            string original = "Hello";
            string reverse;
            for (int i = original.size() - 1; i >= 0; i--) {
            reverse += original[i];
            }
            cout << reverse << endl;


            As you can see in the above example, original is a string variable which holds five characters, and reverse is also a string variable which is about to hold the contents of original in reverse order. In order to reverse the contents of original, we must navigate through it back-to-front.



            original[4] = o
            original[3] = l
            original[2] = l
            original[1] = e
            original[0] = H


            The above characters will be added one by one at each iteration of the for-loop as shown below:



            reverse = "";  //it was empty first
            reverse = reverse + original[4]; // now it holds the last character -> o
            reverse = reverse + original[3]; // now it holds the characters -> ol
            reverse = reverse + original[2]; // now it holds the characters -> oll
            reverse = reverse + original[1]; // now it holds the characters -> olle
            reverse = reverse + original[0]; // now it holds the characters -> olleh





            share|improve this answer


























            • While allocating an array let's say int array[5]. So this array can store 6 elements then?

              – user10655470
              Nov 21 '18 at 19:04











            • @CyborgGamer No it stores 5 elements, and the indexes go from 0 to 4.

              – 0x499602D2
              Nov 21 '18 at 22:33











            • @CyborgGamer No it is not. The confusion will banish once you are more familiar with arrays. Array of size 5 will contains only 5 elements (array[0], array[1], array[2], array[3] and array[4]).

              – Hello World
              Nov 22 '18 at 10:37











            • Hello guys, I am really rusty on arrays. Especially in C. How can I improve my knowledge on array?

              – user10655470
              Nov 23 '18 at 11:04






            • 1





              @CyborgGamer you should try to understand arrays from the scratch. Just ignore using your question as an example. If an array has size of 6, then it will always contain 6 items in it. But instead of accessing the last item using array[6], we will use array[5], because the counting starts from array[0] instead of array[1]. array[0] hold the first item, array[1] the second, ... and array[5] the sixth. It is simple as that.

              – Hello World
              Dec 3 '18 at 5:58














            1












            1








            1







            In you code s is a string variable that holds some characters. And as you said you want to display its contents in reverse order.



            In order to do that, you have to navigate through the contents of s from back to front. To do that, as shown in your code you used for-loop.



            Let's say s contains 10 characters. Since you are accessing your string s back-to-front, the last character found at the 10 - 1 = 9th index, because it starts counting from 0, not 1.



            EDIT with Example



            string original = "Hello";
            string reverse;
            for (int i = original.size() - 1; i >= 0; i--) {
            reverse += original[i];
            }
            cout << reverse << endl;


            As you can see in the above example, original is a string variable which holds five characters, and reverse is also a string variable which is about to hold the contents of original in reverse order. In order to reverse the contents of original, we must navigate through it back-to-front.



            original[4] = o
            original[3] = l
            original[2] = l
            original[1] = e
            original[0] = H


            The above characters will be added one by one at each iteration of the for-loop as shown below:



            reverse = "";  //it was empty first
            reverse = reverse + original[4]; // now it holds the last character -> o
            reverse = reverse + original[3]; // now it holds the characters -> ol
            reverse = reverse + original[2]; // now it holds the characters -> oll
            reverse = reverse + original[1]; // now it holds the characters -> olle
            reverse = reverse + original[0]; // now it holds the characters -> olleh





            share|improve this answer















            In you code s is a string variable that holds some characters. And as you said you want to display its contents in reverse order.



            In order to do that, you have to navigate through the contents of s from back to front. To do that, as shown in your code you used for-loop.



            Let's say s contains 10 characters. Since you are accessing your string s back-to-front, the last character found at the 10 - 1 = 9th index, because it starts counting from 0, not 1.



            EDIT with Example



            string original = "Hello";
            string reverse;
            for (int i = original.size() - 1; i >= 0; i--) {
            reverse += original[i];
            }
            cout << reverse << endl;


            As you can see in the above example, original is a string variable which holds five characters, and reverse is also a string variable which is about to hold the contents of original in reverse order. In order to reverse the contents of original, we must navigate through it back-to-front.



            original[4] = o
            original[3] = l
            original[2] = l
            original[1] = e
            original[0] = H


            The above characters will be added one by one at each iteration of the for-loop as shown below:



            reverse = "";  //it was empty first
            reverse = reverse + original[4]; // now it holds the last character -> o
            reverse = reverse + original[3]; // now it holds the characters -> ol
            reverse = reverse + original[2]; // now it holds the characters -> oll
            reverse = reverse + original[1]; // now it holds the characters -> olle
            reverse = reverse + original[0]; // now it holds the characters -> olleh






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 23 '18 at 13:42









            rioki

            4,07942347




            4,07942347










            answered Nov 21 '18 at 14:18









            Hello WorldHello World

            390212




            390212













            • While allocating an array let's say int array[5]. So this array can store 6 elements then?

              – user10655470
              Nov 21 '18 at 19:04











            • @CyborgGamer No it stores 5 elements, and the indexes go from 0 to 4.

              – 0x499602D2
              Nov 21 '18 at 22:33











            • @CyborgGamer No it is not. The confusion will banish once you are more familiar with arrays. Array of size 5 will contains only 5 elements (array[0], array[1], array[2], array[3] and array[4]).

              – Hello World
              Nov 22 '18 at 10:37











            • Hello guys, I am really rusty on arrays. Especially in C. How can I improve my knowledge on array?

              – user10655470
              Nov 23 '18 at 11:04






            • 1





              @CyborgGamer you should try to understand arrays from the scratch. Just ignore using your question as an example. If an array has size of 6, then it will always contain 6 items in it. But instead of accessing the last item using array[6], we will use array[5], because the counting starts from array[0] instead of array[1]. array[0] hold the first item, array[1] the second, ... and array[5] the sixth. It is simple as that.

              – Hello World
              Dec 3 '18 at 5:58



















            • While allocating an array let's say int array[5]. So this array can store 6 elements then?

              – user10655470
              Nov 21 '18 at 19:04











            • @CyborgGamer No it stores 5 elements, and the indexes go from 0 to 4.

              – 0x499602D2
              Nov 21 '18 at 22:33











            • @CyborgGamer No it is not. The confusion will banish once you are more familiar with arrays. Array of size 5 will contains only 5 elements (array[0], array[1], array[2], array[3] and array[4]).

              – Hello World
              Nov 22 '18 at 10:37











            • Hello guys, I am really rusty on arrays. Especially in C. How can I improve my knowledge on array?

              – user10655470
              Nov 23 '18 at 11:04






            • 1





              @CyborgGamer you should try to understand arrays from the scratch. Just ignore using your question as an example. If an array has size of 6, then it will always contain 6 items in it. But instead of accessing the last item using array[6], we will use array[5], because the counting starts from array[0] instead of array[1]. array[0] hold the first item, array[1] the second, ... and array[5] the sixth. It is simple as that.

              – Hello World
              Dec 3 '18 at 5:58

















            While allocating an array let's say int array[5]. So this array can store 6 elements then?

            – user10655470
            Nov 21 '18 at 19:04





            While allocating an array let's say int array[5]. So this array can store 6 elements then?

            – user10655470
            Nov 21 '18 at 19:04













            @CyborgGamer No it stores 5 elements, and the indexes go from 0 to 4.

            – 0x499602D2
            Nov 21 '18 at 22:33





            @CyborgGamer No it stores 5 elements, and the indexes go from 0 to 4.

            – 0x499602D2
            Nov 21 '18 at 22:33













            @CyborgGamer No it is not. The confusion will banish once you are more familiar with arrays. Array of size 5 will contains only 5 elements (array[0], array[1], array[2], array[3] and array[4]).

            – Hello World
            Nov 22 '18 at 10:37





            @CyborgGamer No it is not. The confusion will banish once you are more familiar with arrays. Array of size 5 will contains only 5 elements (array[0], array[1], array[2], array[3] and array[4]).

            – Hello World
            Nov 22 '18 at 10:37













            Hello guys, I am really rusty on arrays. Especially in C. How can I improve my knowledge on array?

            – user10655470
            Nov 23 '18 at 11:04





            Hello guys, I am really rusty on arrays. Especially in C. How can I improve my knowledge on array?

            – user10655470
            Nov 23 '18 at 11:04




            1




            1





            @CyborgGamer you should try to understand arrays from the scratch. Just ignore using your question as an example. If an array has size of 6, then it will always contain 6 items in it. But instead of accessing the last item using array[6], we will use array[5], because the counting starts from array[0] instead of array[1]. array[0] hold the first item, array[1] the second, ... and array[5] the sixth. It is simple as that.

            – Hello World
            Dec 3 '18 at 5:58





            @CyborgGamer you should try to understand arrays from the scratch. Just ignore using your question as an example. If an array has size of 6, then it will always contain 6 items in it. But instead of accessing the last item using array[6], we will use array[5], because the counting starts from array[0] instead of array[1]. array[0] hold the first item, array[1] the second, ... and array[5] the sixth. It is simple as that.

            – Hello World
            Dec 3 '18 at 5:58











            0














            It is because indexing is zero-based. So the first element is at position zero.



            Since you use c++ you may (and should) use reverse iterators:



            for (auto it = str.rbegin(); it != str.rend(); ++it) {
            char& c = *it;
            //do stuff
            }


            If you have boost you can just do:



            for (auto c : boost::adaptors::reversed(str)) {
            }





            share|improve this answer


























            • How does this answer the OP? And how does it help OP understand zero-based indexes?

              – Jim Rhodes
              Nov 21 '18 at 14:23











            • Yup, this should be a comment.

              – HolyBlackCat
              Nov 21 '18 at 14:24
















            0














            It is because indexing is zero-based. So the first element is at position zero.



            Since you use c++ you may (and should) use reverse iterators:



            for (auto it = str.rbegin(); it != str.rend(); ++it) {
            char& c = *it;
            //do stuff
            }


            If you have boost you can just do:



            for (auto c : boost::adaptors::reversed(str)) {
            }





            share|improve this answer


























            • How does this answer the OP? And how does it help OP understand zero-based indexes?

              – Jim Rhodes
              Nov 21 '18 at 14:23











            • Yup, this should be a comment.

              – HolyBlackCat
              Nov 21 '18 at 14:24














            0












            0








            0







            It is because indexing is zero-based. So the first element is at position zero.



            Since you use c++ you may (and should) use reverse iterators:



            for (auto it = str.rbegin(); it != str.rend(); ++it) {
            char& c = *it;
            //do stuff
            }


            If you have boost you can just do:



            for (auto c : boost::adaptors::reversed(str)) {
            }





            share|improve this answer















            It is because indexing is zero-based. So the first element is at position zero.



            Since you use c++ you may (and should) use reverse iterators:



            for (auto it = str.rbegin(); it != str.rend(); ++it) {
            char& c = *it;
            //do stuff
            }


            If you have boost you can just do:



            for (auto c : boost::adaptors::reversed(str)) {
            }






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 21 '18 at 14:30

























            answered Nov 21 '18 at 14:21









            darunedarune

            1,615617




            1,615617













            • How does this answer the OP? And how does it help OP understand zero-based indexes?

              – Jim Rhodes
              Nov 21 '18 at 14:23











            • Yup, this should be a comment.

              – HolyBlackCat
              Nov 21 '18 at 14:24



















            • How does this answer the OP? And how does it help OP understand zero-based indexes?

              – Jim Rhodes
              Nov 21 '18 at 14:23











            • Yup, this should be a comment.

              – HolyBlackCat
              Nov 21 '18 at 14:24

















            How does this answer the OP? And how does it help OP understand zero-based indexes?

            – Jim Rhodes
            Nov 21 '18 at 14:23





            How does this answer the OP? And how does it help OP understand zero-based indexes?

            – Jim Rhodes
            Nov 21 '18 at 14:23













            Yup, this should be a comment.

            – HolyBlackCat
            Nov 21 '18 at 14:24





            Yup, this should be a comment.

            – HolyBlackCat
            Nov 21 '18 at 14:24


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53413962%2fwhile-extracting-character-from-a-string-in-c-why-do-i-have-to-do-this%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?