fork download
  1. #include <iostream>
  2. #include <memory.h>
  3. using namespace std;
  4.  
  5. void modify(void*& __ptr)
  6. {
  7. char* temp = new char[50];
  8. strcpy(temp,"testing");
  9. __ptr=(void*)temp;
  10. std::cout<<"__ptr="<<(char*)__ptr<<endl;
  11. }
  12.  
  13. int main()
  14. {
  15. char* str;
  16. modify(str);
  17. std::cout<<"str="<<str;
  18. return 0;
  19. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:16:15: error: invalid initialization of reference of type ‘void*&’ from expression of type ‘char*’
     modify(str);
               ^
prog.cpp:5:6: error: in passing argument 1 of ‘void modify(void*&)’
 void modify(void*& __ptr)
      ^
stdout
Standard output is empty