C++輸出字符指針指向的地址


 1 int main()
 2 {
 3     char *s2 = "jwdajkj";
 4     char *s1 = new char[strlen(s2)+1];
 5     
 6     char *s3 = static_cast<char*> (memcpy(s1, s2, strlen(s2) + 1));
 7     printf("%p,%p\n", s3, s1);
 8     cout << s3 << endl;
 9     cout << &s3[0] << endl;
10     cout << static_cast<void*>(s3) << endl;
11 }

需要轉換為void*指針,重載的操作符<<遇到地址會自動輸出字符串


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM