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

18th Oct 2016, 6:46 PM
samira
samira - avatar
8 Antworten
+ 5
string str; while (getline(cin, str)) { cout << str[0]<<endl ; }
18th Oct 2016, 7:11 PM
Forhad Hossain Methun
Forhad Hossain Methun - avatar
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
19th Oct 2016, 2:26 PM
samira
samira - avatar
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; }
17th Nov 2016, 5:31 AM
Forhad Hossain Methun
Forhad Hossain Methun - avatar
- 1
what do you mean navid
19th Oct 2016, 2:12 PM
samira
samira - avatar
- 1
what do you mean navid
19th Oct 2016, 2:12 PM
samira
samira - avatar
- 1
what do you mean navid
19th Oct 2016, 2:12 PM
samira
samira - avatar
- 1
I used for loop for(Int i=1 ; i<=1000;i++) if there are another method tell me plz
19th Oct 2016, 2:36 PM
samira
samira - avatar
- 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.
31st Oct 2016, 8:09 AM
Ehtisham Ahmad
Ehtisham Ahmad - avatar