fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std; // consider removing this line in serious projects
  4.  
  5. int main() {
  6. char filename[10] = "Test";
  7. for(int i=0;i<sizeof(filename);i++) {
  8. cout << i << ": " << filename[i] << "\n";
  9. }
  10. unsigned long value = 0;
  11. for(size_t i=0;i<strlen(filename);i++)
  12. {
  13. value += filename[i]<<(8*(i>>2));
  14. cout << "add to index " << (i>>2) << " " << (filename[i]<<(8*(i&3))) << "\n";
  15. if(((i+1)&3) == 0)
  16. {
  17. cout << "index: " << (i>>2) << " value: " << value;
  18. value = 0;
  19. }
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 5308KB
stdin
1
2
10
42
11
stdout
0: T
1: e
2: s
3: t
4: 
5: 
6: 
7: 
8: 
9: 
add to index 0    84
add to index 0    25856
add to index 0    7536640
add to index 0    1946157056
index: 0    value: 416