how void* iterate for next element
how void* iterate for next element
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include<iostream>
using namespace std;
void check(void *t){
while(*(int*)t){
cout << *(int*)t << endl;
// *(t++);
}
}
int main(){
int a[] = {5,4,7,8,0};
check(a);
}
|
When a void* is type casted to something, it's no longer a void. In you case its now an integer.
If you will not type cast, you cannot do operations on void data types.
Topic archived. No new replies allowed.