After assigning value to int pointer using sscanf, pointer triggers segmentation fault in printf Hot Network Questions Smallest unique number KoTH Nov 25, 2006 printing a pointer. C C Forums on Bytes. 423, 198 Members 1, 771 Online Join Now; My question is how printf() determine which type of pointer is passed to it and prints its value accordingly? I have this doubt as different pointers may have different representation and different size.
So, how does printf Not the answer you're looking for? Browse other questions tagged c pointers printing stdout cout or ask your own question. Printing pointers in C. Ask Question. My first thought was that he just wanted to print numbers to see the values that the compiler had assigned, and casting to void would let him, regardless of any problems in his declarations. What are the differences between a pointer variable and a reference variable in C? 1451.
Nov 14, 2005 Need help? Post your question and get tips& solutions from a community of 423, 306 IT Pros& Developers. It's quick& easy. Treating a char or const char as a pointer to a Cstyle string is a special case, and the only one (that I can think of) that causes operator to print something other than the value of the operand. Sep 28, 2008 cout prints the address only if we want to access the value at address that pointer points we have to use in front of p.
Because the type is void, the compiler says no. If we use visual basic, it has variable with" general type" you can print value of that variable. If you want to print the value OF the pointer (i. e. the address), just use putIN. vb. If you want to print the value the pointer POINTS TO, then you have to know wich type (use for example casts, like you did in the constructor.
Here, type is the pointer's base type; it must be a valid C type and varname is the name of the pointer variable. The asterisk you used to declare a pointer is the same asterisk that you use for multiplication.