I manually assigned characters from a string to another array of string. But why it results in having 0 length and cannot be directly printed? although the characters in the string can be printed by iterating.
Code:
#include <iostream>
#include <string.h>
using namespace std;
int main() {
string domain[100],text="google";
for(int i=0;i<6;i++){
domain[0][i] = text[i];
}
for(int k=0;k<6;k++){
cout<<domain[0][k];
}
cout<<endl;
cout<<"String length: "<<domain[0].length()<<endl;
cout<<"Output string directly from array : "<<domain[0]<<endl;
return 0;
}
Output :
google
String length: 0
Output string directly from array :