DEV Community

Discussion on: Caesar Concatenation

Collapse
 
pgradot profile image
Pierre Gradot • Edited
for (int i = 0; str[i]; i++) { 
        char ch = str1[i];
       str[i] = ch + 1;
}
Enter fullscreen mode Exit fullscreen mode

ch can be reference to avoid writing str[i]. Instead you can write ch = ch + 1. If the index is not used in computations, you may use a range-based for loop:

for (auto &ch : str) { 
       str[i] = ch + 1;
}
Enter fullscreen mode Exit fullscreen mode

#include <bits/stdc++.h>

Weird include.