c++ - Values of array elements remain unchanged -


i new c++. below program converting integer array. value of array not change initialized value.

#include <iostream> #include <algorithm> using namespace std;  int main(){      int n,i=0;     cin >> n;     int arr[100]={0};     while(n){         arr[i]=n%10;         i++;         n=n/10;         cout<<arr[i];     }  return 0; } 

the value of arr[i] printed 0. not understand error. can please tell error.

try increment i after printing

cout << arr[i] << endl;  i++; 

Comments

Popular posts from this blog

php - Extract Text from HTTP referer -

java - Callback from new thread to class from which thread was initiated -

Receive udp packets in android gstreamer -