Answer the question
In order to leave comments, you need to log in
Problem with strings in c++?
Hello, please help with the solution. At the university, a task was given for laboratory work: Enter a list of the names of students in the group, request a coherent text consisting of several sentences, where previously entered surnames are used. Correct the entered text so that only surnames and the first words in sentences are capitalized.
The only thing with which there are difficulties is how to correct the names in the entered text.
Here is the code:
#include <iostream>
#pragma warning(disable : 4996)
using namespace std;
int main()
{
char lastname[1000];
char text[1000];
cout << "Enter the last names of all students in your group:" << endl;
gets(lastname);
cout << "Enter the text with last names entered earlier:"<<endl;
gets(text);
text[0] = toupper(text[0]);
for (int i = 0; text[i] != '\0'; ++i){
if (text[i] == '.'){
text[i+1] = toupper(text[i+1]);
}
}
cout << text << endl;
system("pause");
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question