char temp[200] = "I am from Jupiter"
string useful ; // the useful is the word "Jupiter"
int maxle = 0 ;
maxle = strlen(temp); //max length temp
for(int i=0; i<maxle; i++)
useful[i] = temp[10+i] ;
and my problem is that if you try :
cout << useful ;
you will have no answer! The compiler does not recognize the useful like string but char . Any help, please .
This is "very bad". Just like arrays, if you use [] to access beyond the boundaries, you corrupt memory. Note you cannot add new characters with the [] operator. You can only read/modify existing ones.
In this case, since 'useful' contains an empty string, everything is an out-of-bounds access.
Based on http://www.cplusplus.com/reference/algorithm/remove/ there is this line "Notice that this function does not alter the elements past the new end, which keep their old values and are still accessible."
So it seems remove function does NOT remove elements. All it does is to push those to be deleted to the end. To truly delete those is to call the erase method of the container classes you are using.