Speedi3579
November 30th, 2004, 04:03 PM
Hello,
I am writing a program that uses my own function to reverse a string and print the reverse. I am experiencing an error that I just don't know why it is occuring. Here is the code block, and the error:
int main()
{
char myString[] = "aBc123";
char revString[80] = "1";
char *ch;
ch = ToUpperStr(myString);
revString = ReverseStr(myString, revString); // error, left operand must be l-value
printf("%s\n%s\n", myString, ch);
return 1;
}
and for clarification, here is my ReverseStr() function code(Note: it currently doesn't reverse the string, I'm holding off on writing that part until I get this current little error fixed):
char* ReverseStr(char * str, char * reverseStr)
{
// char *strStart = str;
char *revStart = reverseStr;
while (*str)
{
*reverseStr = *str;
str++;
reverseStr++;
}
reverseStr = revStart;
return reverseStr;
}
Does anyone know why my function can't return the address properly to revString? Is there something I am missing here? I want my function to return the address of the modified string, and the function should be passed the address that I want to place the modified string at.
Thanks in advance for your help,
Alan.
I am writing a program that uses my own function to reverse a string and print the reverse. I am experiencing an error that I just don't know why it is occuring. Here is the code block, and the error:
int main()
{
char myString[] = "aBc123";
char revString[80] = "1";
char *ch;
ch = ToUpperStr(myString);
revString = ReverseStr(myString, revString); // error, left operand must be l-value
printf("%s\n%s\n", myString, ch);
return 1;
}
and for clarification, here is my ReverseStr() function code(Note: it currently doesn't reverse the string, I'm holding off on writing that part until I get this current little error fixed):
char* ReverseStr(char * str, char * reverseStr)
{
// char *strStart = str;
char *revStart = reverseStr;
while (*str)
{
*reverseStr = *str;
str++;
reverseStr++;
}
reverseStr = revStart;
return reverseStr;
}
Does anyone know why my function can't return the address properly to revString? Is there something I am missing here? I want my function to return the address of the modified string, and the function should be passed the address that I want to place the modified string at.
Thanks in advance for your help,
Alan.