Initializer_list

After running the program below, I get an extra 0 (zero) after the output.
Is this a Null character at the end of the string? And how can i remove this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <initializer_list>

void PrintIList(std::initializer_list<std::string> add)
{
    int Total = 0;
    for (auto beg = add.begin(); beg != add.end(); ++beg)
    {
        std::cout << *beg;
    }
    std::cout << Total;
}

int main()
{
    std::initializer_list<std::string> ili = {"Some ","sample ","text."};
    PrintIList(ili);
}
std::cout << Total;

You are declaring Total = 0 in that function, and then you are printing it after the for loop. The initializer list has nothing to do with this number.
No, that's because you also print the value of Total, which indeed is 0 :)
Thank's for the replies.

I was playing around with Integer's to learn initializer_list, Then changed to string's and forgot to about Total :)
Topic archived. No new replies allowed.