1 votes 1 votes how can int pointer be used to point to string constant??? even if we consider that address was passed to int pointer then when while(*++p1) is executed it must raise error right bcoz we are using int pointer??? Programming in C programming pointers + – Rahul Jain25 asked Dec 21, 2016 Rahul Jain25 760 views answer comment Share Follow See all 8 Comments See all 8 8 Comments reply Show 5 previous comments Rahul Jain25 commented Dec 21, 2016 reply Follow Share By the way arithmetic operation is not allowed between pointers, right???? 0 votes 0 votes Rahul Jain25 commented Dec 21, 2016 reply Follow Share no i dont think they are working with ascii value because * not used. 0 votes 0 votes ManojK commented Dec 21, 2016 reply Follow Share Undefined behavoir in C because we can,t use integer pointer to point to a string literal and both integet and char have different alignment requirement . 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes char will be automatically typecasted to int without the loss of data I think the output will be 3. ANOOP BHANDARIRI answered Dec 21, 2016 • edited Dec 21, 2016 by ANOOP BHANDARIRI ANOOP BHANDARIRI comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments ManojK commented Dec 21, 2016 reply Follow Share You can't perform multiplication and division on pointers (bcz No meaning ),but you can do addition and subtraction on pointers 2 votes 2 votes ManojK commented Dec 21, 2016 reply Follow Share Even one more thing to note; Addition of two pointers is not allowed. It doesn’t make logical sense to add two pointers because you won’t know what the new address will be. You’ll get a compiler error if you attempt to perform such an operation. But subtraction of two pointers is allowed since this will give you the number of elements lying between the two addresses. 2 votes 2 votes ANOOP BHANDARIRI commented Dec 21, 2016 reply Follow Share subtraction of two same type of pointers is allowed in case of array or string and the result gives the no of elements between them. 0 votes 0 votes Please log in or register to add a comment.