problm with int pointer in C++ -
problm with int pointer in C++ -
     int *sub(int *a,int q) {     int = id(a,q)+1,j = id(a,q)-1;     int *l , *m ;     m = (int*)malloc(sizeof(int));     *m = q;     l = m ;     for(i ; *(a+i) != '\0' && *(a + i) >= q ; ++i)     {       ++l = (int*)malloc(sizeof(int));       *l = *(a+i);     }     ++l = (int*)malloc(sizeof(int));     *l = '\0';     for(j ; j>=0 && *(a + j) >= q  ; j--)     {         --m = (int*)malloc(sizeof(int));         *m = *(a+i);     }     for(i = 0 ; *(m + i) != '\0' ; i++)         cout<<*(m+i)<<"##\t";       homecoming m; }    
it's function supposed take pointer 1d array (a) ,  homecoming pointer 1d array(m) subarray of , has elements greater or equal q(passed parameter function sub) guess there problem way manipulate int pointers.
   #include <iostream> #include <string> #include <vector> #include <algorithm>   int _tmain(int argc, _tchar* argv[]) {     std::vector<int> arr = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };     int q = 5;     std::vector<int> result;     std::copy_if(arr.begin(), arr.end(), std::back_inserter(result), [q](int i){return >= q; });     std::for_each(result.begin(), result.end(), [](int i){std::cout << << std::endl; });     getline(std::cin, std::string());      homecoming 0; }       
 c++ 
 
Comments
Post a Comment