Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Shifting indices of an array.

  1. Feb 28, 2012 #1
    So Im trying to use for loops to shift the index an array by a user inputted value. The code i have so far is
    cin >> choice;
    if(choice == 2){
    cout << endl;
    cout <<"Please enter the desired number of shifts:" << endl;
    cin >> b;
    int s;
    for (s = 0; s == b;s++) {
    cout << message[s + b];

    When I try to compile it, it doesn' cout the message. The input from the message occurs earlier in the code.
  2. jcsd
  3. Feb 28, 2012 #2


    User Avatar
    Science Advisor
    Gold Member

    Have a think about why you put s == b in the for loop. It doesn't make any sense at all.
  4. Feb 28, 2012 #3
    yeah, right after i posted the thread i realized that and fixed it and now it works. thanks though.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook