Exforsys

Online Training

stripos function

This is a discussion on stripos function within the C and C++ forums, part of the Programming Talk category; hello, I have a problem. I will create a C function (strPos) that will return position of first occurence of ...


Go Back   Exforsys > Programming Talk > C and C++

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-17-2008, 12:56 PM
Junior Member
 
Join Date: Mar 2008
Posts: 1
lexxzy is on a distinguished road
stripos function

hello,
I have a problem.
I will create a C function (strPos) that will return position of first occurence of a case-insentitive string found in the stackOfStr string. The target may be a string of one or more characters. If target string is not found, it will return -1. The offset means the starting location of the search.

The function strPos() are not allowed to use any C library function calls.


the syntax of the strPos function is this:
int strPos(char *stackOfStr, char* target, int offset)

Does anyone has an idea about this?
Please I need a serious and exact answer for this.
Thank you in advance.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-23-2008, 09:03 AM
Junior Member
 
Join Date: Sep 2008
Posts: 1
sally9 is on a distinguished road
strpos c

you might want to try something like this


Code:
int strpos(char *str,char *term)
{
  int r=0;
  while( *str != 0)
  {
    if( *str==term[0] )
      for(int i=1;i<300;i++)
      {
        if(term[i]==0) return r;
        if(str[i]!=term[i]) break;
      }
    str++;
    r++;
  }
  return -1;
}
hrindustries . co . uk
Time and Attendance Solutions From HR Industries
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new questions
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 06-15-2004 06:00 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 06-01-2004 06:01 AM
comp.lang.c FAQ list Table of Contents Steve Summit Tech FAQ 0 06-01-2004 06:00 AM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit Tech FAQ 0 06-01-2004 06:00 AM
comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) Steve Summit Tech FAQ 0 05-15-2004 06:00 AM


All times are GMT -4. The time now is 07:18 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.