I am trying to read lines until there is an empty line and then extract first words from the lines.
on each line there is 2 words. word1 and word2. the number of lines is not known. but there is an empty line after those word lines.
example input:
word1 word2
word11 word22
word111 word222
some other text here
here is my code:
#include <iostream>
using namespace std;
int main() {
int i;
string line;
string wrd1[100], wrd2[100];
for(;getline(cin,line),!line.empty();) {
for(i=0;i<line.size();i++) {
if(line[i] == 32) break;
else wrd1[i] = line[i];
}
cout << wrd1 << endl;
}
return 0;
}
but the output is in hexadecimal for some reason!
0x7fff753dad10
0x7fff753dad10
0x7fff753dad10
how do output them normally as they are (word1, word111...) and not in hexadecimal? Or why does it output in hexadecimal anyway?