Skip to content

Instantly share code, notes, and snippets.

@timothy
Created July 12, 2017 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timothy/8cbdd1b6ce4b5e74889f90cbc9b3020b to your computer and use it in GitHub Desktop.
Save timothy/8cbdd1b6ce4b5e74889f90cbc9b3020b to your computer and use it in GitHub Desktop.
circular count within a loop
//circular count within a loop example
std::string key = "12345";
for (int i = 0, j = 0; i < 30; ++i)
{
std::cout << j;
j = (int) ((j + 1) % key.length());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment