# chain problem

• ### Question

• How to generate a chain: a, b,........,........ zz, ... ... ... azz.......... infinity and assign it to for instruction as loop .

and assign the numeric value, growing.

Oryginał

Tuesday, October 18, 2016 6:44 PM

### All replies

• How to generate a chain: a, b,........,........ zz, ... ... ... azz.......... infinity and assign it to for instruction as loop .

and assign the numeric value, growing.

You would need to specify more carefully what you mean by this.

Are you asking how to generate keys (a, b, ..) or how to assign increasing values to these keys (or both)?

David Wilkinson | Visual C++ MVP

Tuesday, October 18, 2016 8:02 PM
• Thank You for Your answer .

I think about both issues . I would like to generate loops for many times .

Tuesday, October 18, 2016 9:23 PM
• Thank You for Your answer .

I think about both issues . I would like to generate loops for many times .

Then what does "assign the numeric value, growing" mean?

David Wilkinson | Visual C++ MVP

Tuesday, October 18, 2016 9:30 PM

when i write 1 then i have  : "for a=" , when i write 2 then i have :"for a=" and "for b=" etc.

Tuesday, October 18, 2016 9:44 PM

when i write 1 then i have  : "for a=" , when i write 2 then i have :"for a=" and "for b=" etc.

What does "when i write 1" (etc) mean?

If you are thinking about nested for loops, perhaps you should be looking at a recursive function.

David Wilkinson | Visual C++ MVP

Wednesday, October 19, 2016 12:25 AM
• Hi RB_1,

thanks for posting here.

>>How to generate a chain: a, b,........,........ zz, ... ... ... azz.......... infinity and assign it to for instruction as loop .

In my understanding, are you going to generate a character chain like this ?

Best Regards,
Sera Yu

We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

• Proposed as answer by Tuesday, November 1, 2016 2:03 AM
Wednesday, October 19, 2016 3:07 AM
• Try this too:

```// 1 -- generate 'a', 'b', ..., 'z';
// 2 -- generate 'aa', 'ab', ..., 'zz';
// etc.
int how_many = 2;

string s( how_many, ' ' );

function<void( int )> f;
f = [=, &f, &s]( int i )
{
for( char c = 'a'; c <= 'z'; ++c )
{
s[i] = c;
if( i < how_many - 1 )
{
f( i + 1 );
}
else
{
cout << s << " ";
}
}
};

f( 0 );

cout << endl;
```

• Proposed as answer by Thursday, October 20, 2016 11:33 AM
Wednesday, October 19, 2016 5:13 AM

I have problem with "stdafx" , fatal error C 1083 :Cannot open include file :'stdafx.h':No such file or directory .

Wednesday, October 19, 2016 12:43 PM

I have problem with "stdafx" , fatal error C 1083 :Cannot open include file :'stdafx.h':No such file or directory .

What kind of project did you create? If you created a Win32 Console Application with default settings, it should have created a project with a "stdafx.h" file for generating the precompiled header.

You have been posting here for a while; you must have successfully created projects before.

David Wilkinson | Visual C++ MVP

Wednesday, October 19, 2016 1:01 PM
• Thank You for Your answer .

In Your program , You placed all marks in keyboard . I think about marks such as in Microsoft Office Excel in board :

a,......z,aa,ab,az,....bz,....zzz......infinity .

Wednesday, October 19, 2016 7:20 PM
• One approach is shown here (in javascript, but hopefully you can figure it out.)

Wednesday, October 19, 2016 8:14 PM