Flagging

I have an alliteration:
Alice’s aunt ate apples and acorns around August.

I need to take the first letters of every word which would be like this:
 
Aaaaaaaa

By using the concept of flagging where it goes something like this:
If flag is up, take the letter, if flag is down, skip.

I've tried writing the code but I've only gotten this:
PS: Need to read from a file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <fstream>
using namespace std;

int main(){
fstream file("alli.in");
char arr[10] = {'\0'};
string s;
int flag = 1;

while(getline(file,s)){
    for(int i=0;i<s.length();i++){
        if(s[i]!=' '){
            flag = 0;
        }
        else flag = 1;
        if(flag=1){
            s[i]=arr[i];
            cout << arr[i];

        }




    }


}
return 0;}
What does the flag stand for ?

Instead of getting the whole line from file and then executing a loop, get individual letters from the file which are immediately after a space (it will be the first letter of the word). If it is 'a' or 'A' output the character.
Topic archived. No new replies allowed.