Ok, I need to write a program that capitalizes the first letters of a given sentance.
I am completely lost doing this.
I just need a kick in the right direction if someone could help.
Printable View
Ok, I need to write a program that capitalizes the first letters of a given sentance.
I am completely lost doing this.
I just need a kick in the right direction if someone could help.
if you want to just capitalise the first letter of the sentence then do this:
if you need to do the first letter of every word in the sentence then do this:Code:#include <ctype.h>
void Capitalize(char* sentence)
{
if(sentence && strlen(sentence) > 0)
{
sentence[0] = toupper(sentence[0]);
}
}
hope this helps!Code:#include <ctype.h>
void Capitalize(char* sentence)
{
int i = 0;
int length;
if(sentence && strlen(sentence) > 0)
{
length = strlen(sentence);
while(i < length)
{
if(sentence[i] == ' ' && i < length - 1)
{
sentence[i + 1] = toupper(sentence[i + 1]);
}
i++;
}
}
}
U.