Search
 
SCRIPT & CODE EXAMPLE
 

CPP

program to convert int to int array c++

#include <iostream>
#include <vector>
using namespace std;

vector <int> integerToArray(int x)
{
    vector <int> resultArray;
    while (true)
    {
    resultArray.insert(resultArray.begin(), x%10);
    x /= 10;
    if(x == 0)
        return resultArray;
    }
}

int main()
{
    vector <int> temp = integerToArray(1234567);
    for (auto const &element : temp)
        cout << element << " " ;
    return 0;
}

//outputs 1 2 3 4 5 6 7 
Comment

PREVIOUS NEXT
Code Example
Cpp :: for loop reverse C++ 
Cpp :: cuda __constant__ 
Cpp :: C++ Kilometers Per Hour to Miles Per Hour Conversion 
Cpp :: google test assert eq float 
Cpp :: qt messagebox 
Cpp :: c++ default array value not null 
Cpp :: c++ find index of an element 
Cpp :: cuda extern __shared__ 
Cpp :: c++ srand() 
Cpp :: c++ check open processes 
Cpp :: fast io c++ 
Cpp :: casting pointer (int to char*) in c++ 
Cpp :: PI IN C++ WITH CMATH 
Cpp :: arduino led code 
Cpp :: Matrix multiply using function c++ 
Cpp :: rank() in c++ 
Cpp :: how to initialize 2d vector in c++ 
Cpp :: C++ mutex lock/unlock 
Cpp :: switch in c++ 
Cpp :: minimum spanning trees c++ 
Cpp :: how to iterater map of sets in c++ 
Cpp :: return by reference in cpp 
Cpp :: 2d vector cpp 
Cpp :: http.begin() error 
Cpp :: c++ printf char as hex 
Cpp :: singleton c++ 
Cpp :: how to clear vector c++ 
Cpp :: memset in c++ 
Cpp :: convert string to lpstr 
Cpp :: change int to string c++ 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =