int function not returning a value.

Hey people, this simple little program is not returning a value. The output is

" (string) contains characters" (The number of characters is supposed to display between the 'contains' and 'characters.'

However, if I go to the function and cout the length, the cout in the main body displays just fine.

Here's the main portion :
1
2
3
4
5
6
	cout << "'" << input << "' contains "; //Output of character count.
	
	charCount(input);
	
	cout << " characters, including any spaces.\n"; //Output of character count.


and here's the function.
1
2
3
4
5
6
7
8
9
10
11
12
13
int charCount(char *string)
{
	int length = 0; //Variable to hold the number of characters.
		
	//Gets the number of characters contained in *string and puts that number into length.
	while (*string != '\0')
	{
		length += 1;
		string++;
	}
		
	return length; //Return the value of length.
}
cout << charCount(input);
Oh my. Lol. Thanks. Didn't notice that! Something about looking at code for too long...
Topic archived. No new replies allowed.