trying to fill a c++ string

I have used getline to read a line into a string.
now I need to go through the that string index by index
I have a for loop it reads through the string
I need to create another string that has ? marks for isalpha
and shows everything thing, else it is a puzzle.
I can get it to cout puzzle but how do I put the output into string puzzle
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
32
33
34
35
36
37
38
39
int  InitializeArrays (string& phrase , string& puzzle )

	{
	ifstream inFile;			
	string  filename;
	int linelength;
	
	  cout << "please enter file name name + .txt-->"; //user prompt
		 cin >> filename;
		 inFile.open (filename.c_str() );

	       while (!inFile)                          // prompt check and loop
		{
			cout << "please enter file name name + .txt-->";
			cin >> filename;
			inFile.open (filename.c_str() );		// c str conversion
		}
		
	   getline (inFile, phrase);
		 linelength = phrase.length ();
	   
				for ( int i = 0 ;i < linelength; i++)

					if 
					(isalpha (phrase[i]))
					cout << "*" ;
					else 
						cout << phrase[i];
					
			
				
			
	
						
					

		   return (linelength);

	}

hello pistol1,

This will create a string named puzzle with '?' for isalpha()
1
2
3
4
5
6
7
8
9
10
11
12
13
    string  puzzle;
...
                    if 
                    (isalpha (phrase[i]))
                    {
                        puzzle += '?';
                        cout << "*" ;
                    }
                    else 
                    {
                        puzzle += phrase[i];
                        cout << phrase[i];
                    }
Topic archived. No new replies allowed.