I want to make a simple singly linked list. The conversion constructor in the class "slist" is slist(const char* c) and I want it to just take a string, reverse it, and prepend it so that each letter in the string is a node in the linked list.
Conversion Constructor
Code:
slist::slist(const char* c)
{
int i;
int len = strlen(c);
char temp;
for (i = 0; i < len/2 ; i++){ //Stops when half the string is reached
temp = c[i];
c[i] = c[len-1-i]; //First char is set to last
c[len-1-i] = temp; //Last char is set to first
}
for(i = 0; i < len; i++)
prepend(c[i]);
}
The error I'm getting says that on these lines...
Code:
c[i] = c[len-1-i]; //First char is set to last
c[len-1-i] = temp; //Last char is set to first
"assignment of read-only location"
What does that mean? Tell me if you need more code like the class or any other functions.