The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 01-25-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 741
Code:
int *ptr=5;
Pointer can only be initialized to zero or null if it does not point to a variable of that type.

Code:
char *str="helloworld\n";
printf("string value is %s\n",*str)
The "%s" conversion specification takes a pointer argument not the actual character that *str points to. So if you want to print the entire string...

Code:
printf("string value is %s\n", str);
and if you want to print the character that *str points to...

Code:
printf("str points to %c\n", *str);