Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
Uggghhh.... I tested that code (just to test the word thing) and it does not work... I revised it some, still does not work. I think I might have time to fix it later tonight, but I am not sure .
Harq wrote:
Uggghhh.... I tested that code (just to test the word thing) and it does not work... I revised it some, still does not work. I think I might have time to fix it later tonight, but I am not sure .


Yes, we already told you it won't work right. The most obvious offender is


Code:
void convert_to_lower(string string) {  //converts the input to lower case
     int length = string.length();
     
     for (int c = 0; c < length; c++)  //loops through input
     string[c] = tolower(string[c]);
}


for 2 reasons. One, you shouldn't name the variable the same as a type, the compiler might choke on that. 2, it won't modify the string you pass as an argument because it is a local variable. You aren't passing it as a pointer, hence it will be modifying a copy and not the original. You can solve that in two ways. 1) pass it as a pointer, or the more logical 2) just return the new string Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement