-
A little help, please
Hi everyone, I am new to the field of programming and I do not have much experience with C. Can you help me with solving the 2 requirements of my topic? Please very much.
Requirement 1 - Uppercase
The written program will have to correct each verse so that the first word starts with a capital letter, the rest of the alphabetical characters in the verse are lowercase.
Example: It paSsEs thE SwAn on thE waTeR
it becomes: It passes the swan on the water
Requirement 2 - Trimming
Identify sentences with unnatural spacing and remove this redundant whitespace, so that if there were more spaces between two consecutive words, now there will be only one. In some cases, in addition to eliminating redundant whitespace, all non-alphabetic characters are also removed:{'.', ',', ';', '!', '?', ':'}
Example: It :.. passes ;;, the swan on .... ?? the .,, water
it becomes: It passes the swan on the water
-
-
Break the problem down into simpler achievable steps.
This is your first program.
Code:
int main ( ) {
char buff[100];
while(fgets(buff,sizeof(buff),stdin)) {
printf("%s",buff);
}
}
Prove you can just read input and print it back out.
This is your second program.
Code:
// Example: It paSsEs thE SwAn on thE waTeR
// it becomes: It passes the swan on the water
void Uppercase( char *buff ) {
// Write your code here.
}
int main ( ) {
char buff[] = "It paSsEs thE SwAn on thE waTeR\n";
Uppercase(buff);
printf("%s",buff);
}
Prove you can transform a given example.
When (and only when) both work, you can merge them together like so.
Code:
// Example: It paSsEs thE SwAn on thE waTeR
// it becomes: It passes the swan on the water
void Uppercase( char *buff ) {
// Write your code here.
}
int main ( ) {
char buff[100];
while(fgets(buff,sizeof(buff),stdin)) {
Uppercase(buff);
printf("%s",buff);
}
}