this is how i insert character in array of character.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
char arraytest[10];
int position;
char insert;
cout<<"Enter element to be inserted : ";
cin>>insert;
cout<<"Position to insert? : ";
cin>>position;
int p = position;
for(int x=size; x>p; x--)
{
array[x]=array[x-1];
}
arraytest[p]=insert;
is this possible when im using string? i don't want to use the build in string function like insert or use vectors and i want it like simple algorithms that i used in array characters.
Yes it is possible. Just replace "array", BTW not a good choice for a variable name, with the name of a string. At its core a "std::string" is an array and it is the string class that handles most of the work for you.
I do question the use of the for loop and wonder if it is inserting properly.
Without more of the code to know what you have I have no way of testing this.