Char[] в string
Вводим массив char[], необходимо перевести его в string. В последнем цикле s получает значения char, но почему-то str ничего не запоминает:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int i=0, N=0;
string s, str="";
char words[N][30], a;
while(a!='\n')
{
cin>>words[i];
i++;
N++;
a=getchar();
}
for(i=0;i<N;i++)
{
s=string(words[i]);
str=str+s+' ';
cout<<s;
}
cout<<str;
}