Relative Content

Tag Archive for c++pointersg++clang

clang++ and g++ Compiler gives different output when printing char pointer [duplicate]

This question already has answers here: Garbage value in pointer to char (1 answer) cout << with char* argument prints string, not pointer value (6 answers) Closed 10 mins ago. clang++ and g++ Compiler gives different output when printing char pointer #include <iostream> int main(int argc, char** argv){ char a = ‘a’; char* aptr = […]

Compiler divergence in printing of char pointer

#include <iostream> int main(int argc, char** argv){ char a = ‘a’; char* aptr = &a; std::cout << aptr << ” : ” << a << std::endl; return 0; } when I compile the code using g++, it gives me the output: a : a but when I compile using g++, it gives me the output: […]