Function?

This is a discussion on Function? within the C Programming forums, part of the General Programming Boards category; int Test ( char* mm, char* i, int offset ) Find position of first occurrence of a case-insensitive string Returns ...

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    2

    Function?

    int Test ( char* mm, char* i, int offset )
    Find position of first occurrence of a case-insensitive string
    Returns the numeric position of the first occurrence of i in the mm string. Note that the i may be a string of one or more characters. If i is not found, Test() will return -1.
    Can anyone help with this function?

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by kwikwisi View Post
    int Test ( char* mm, char* i, int offset )
    Find position of first occurrence of a case-insensitive string
    Returns the numeric position of the first occurrence of i in the mm string. Note that the i may be a string of one or more characters. If i is not found, Test() will return -1.
    Can anyone help with this function?
    Sure. What's your problem?

    We don't DO your homework for you. You show us your work, and tell us what your problem is, and we'll assist you with that problem.

    Perhaps for a string search, you should be looking at string functions?

  3. #3
    ari
    ari is offline
    Registered User
    Join Date
    Aug 2008
    Posts
    2
    any other inputs??
    like the complexity etc and also

    u perhaps want me to write "strcasecmp" ??

    [edited to subscribe to the post]
    Last edited by ari; 08-19-2008 at 01:00 AM.

  4. #4
    Registered User
    Join Date
    Aug 2008
    Posts
    2
    Actually I'm not familier with C Program and I'm .Net programmer.
    May i request it for some urgent usage?
    Thanks in advance

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,420
    A simple solution is to use toupper() (or tolower()) to make the case of both the subject and search strings (or a copy of them) uniform, and then use strstr() to find the address of the initial char of the substring. To get the position of the substring from this address, subtract the address of the initial char of the subject string (assuming that strstr() does not return NULL, in which case the search string is not a substring since it cannot be found in the subject string).
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by kwikwisi View Post
    Actually I'm not familier with C Program and I'm .Net programmer.
    May i request it for some urgent usage?
    Thanks in advance
    So what have you got so far, what exactly are you struggling with?

    You must understand that we are not here to write your assignment for you. We will help you overcome stumbling blocks where you do not understand something, but to do that, we need to see where you are at and exactly what you are struggling to do.

    If you haven't written any code yet, perhaps you can write it in "pseudo-code", which is more like English to describe what you want to do.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21