linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* substring offset
@ 2002-08-31 18:11 Ken Martwick
  2002-08-31 21:21 ` Ibraheem Umaru-Mohammed
  0 siblings, 1 reply; 2+ messages in thread
From: Ken Martwick @ 2002-08-31 18:11 UTC (permalink / raw)
  To: linux-c-programming

In this code snippet,
 
          findptr = strstr(realine[n], search);
          if(findptr)
               {
               diff = (int)(findptr - realine[n]);
 
why isn't "diff" the offset of "search" in "realine[n]"?  How
can I calculate the offset?
Ken Martwick



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: substring offset
  2002-08-31 18:11 substring offset Ken Martwick
@ 2002-08-31 21:21 ` Ibraheem Umaru-Mohammed
  0 siblings, 0 replies; 2+ messages in thread
From: Ibraheem Umaru-Mohammed @ 2002-08-31 21:21 UTC (permalink / raw)
  To: Ken Martwick; +Cc: linux-c-programming

["Ken Martwick"="Ken"]
Ken >> In this code snippet,
Ken >>  
Ken >>           findptr = strstr(realine[n], search);
Ken >>           if(findptr)
Ken >>                {
Ken >>                diff = (int)(findptr - realine[n]);
Ken >>  
Ken >> why isn't "diff" the offset of "search" in "realine[n]"?  How
Ken >> can I calculate the offset?
Ken >> Ken Martwick
Ken >> 

You want to use the address of realine[n]. i.e
	
			,---- <code> 
			| ...
			| findptr = strstr(&realine[n],search);
			| if( findptr )
			| {
			|   diff = findptr - &realine[n];
			|   ...
			`----<code/>

Kindest regards,

				--ibz.

-- 
				Ibraheem Umaru-Mohammed 
					"ibz"
			umarumohammed (at) btinternet (dot) com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-08-31 21:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-31 18:11 substring offset Ken Martwick
2002-08-31 21:21 ` Ibraheem Umaru-Mohammed

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).