'Get string of characters from a vector of strings where the resulting string is equivalent to the majority of the same chars in the nth pos in strings

I'm reading from a file a series of strings, one for each line. The strings all have the same length.

File looks like this:

010110011101
111110010100
010000100110
010010001001
010100100011
[...]

Result : 010110000111

I'll need to compare each 1st char of every string to obtain one single string at the end. If the majority of the nth char in the strings is 1, the result string in that index will be 1, otherwise it's going to be 0 and so on.

For reference, the example I provided should return the value shown in the code block, as the majority of the chars in the first index of all strings is 0, the second one is 1 and so on.

I'm pretty new to C++ as I'm trying to move from Web Development to Software Development. Also, I tought about making this with vectors, but maybe there is a better way. Thanks.

c++


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source