Stopping a character array from printing directly to the screen

I am currently taking a programming course (my first one) and we were assigned to create a program that translates a block of text from English to pig Latin. One of the things the program must do is capitalize and "de" capitalize an input word, (if the word contains uppercases), such that, for instance "Programming" translates to "Ogrammingpray" and not "ogrammingPray." I tried doing this by creating a function that first changes "Programming" to "programming" (i.e. changes the first letter to lowercase). The function looks like this:


string changes_string_to_char_changes_to_lower (string word)
{
	int i=0;
	char c;
	while (word[i])
	{
		c=word[i];
		putchar (tolower(c));
		i++;	
	}


	return word;


While it does change the casing of the letter, when I call the function in my other function that does the translation, the program outputs two words: the word with all lowercases followed by the translated word. For "Programming" it outputs "programmingogrammingPray". What can I do so that the function "string changes_string_to_char_changes_to_lower (string word)" does not output the word it is doing the work on, but simply performs the function and stores the word?
word[i] = tolower( word[i] );
Though only the first letter can be capitalized, so why do this in a loop?
Also, "changes_string_to_char_changes_to_lower" is both ridiculously long and unclear name. You'd think that making a longer name would give a better explanation of what the function does, but...
How about "change_string_to_lowercase" or something..
Topic archived. No new replies allowed.