How do I compare an int variable and a string variable in if statement
how to do if array[j] == blank or char/string then break?
Can somebody explain? I have no idea how to do this, I'm a beginner
#include <algorithm>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
int main()
{
std::string aa = " ";
std::vector<int> array(5);
for (int j = 0; 0 < 5; j += 1) {
array.push_back(1);
std::cin >> array[j];
if (array[j] < aa) {
break;
}
}
for (int startIndex = 0; startIndex < array.size() - 1; ++startIndex)
{
int smallestIndex = startIndex;
for (int currentIndex = startIndex + 1; currentIndex < array.size(); ++currentIndex)
{
if (array[currentIndex] < array[smallestIndex])
smallestIndex = currentIndex;
std::cout << currentIndex << " ";
}
std::swap(array[startIndex], array[smallestIndex]);
}
for (int index = 0; index < array.size(); ++index)
std::cout << array[index] << ' ';
}