0
I need to write program that print only the first letter of every line? Who can help me?
I need it for my homework
8 Respostas
+ 5
string str;
while (getline(cin, str))
{
cout << str[0]<<endl ;
}
0
thanks forhad
but if I like to enter a pargraph . with four lines for example
we love our families
our families love us
I miss my mom and dad if I left them
here the program must print
w
o
I
0
int number_of_lines;
scanf("%d\n", & number_of_lines) ;
vector<string> lines;
for(int i =0;i<number_of_lines;i++){
string str; getline(cin, str);
lines. push_back(str);
}
for(int i =0;i<number_of_lines;i++){
cout <<lines[i][0] <<endl;
}
- 1
what do you mean navid
- 1
what do you mean navid
- 1
what do you mean navid
- 1
I used for loop
for(Int i=1 ; i<=1000;i++)
if there are another method tell me plz
- 1
You mean you want to write everything in the code but the code should only print the first letters? If yes then what is the purpose to type the complete sentences? Just type the first letters only.