Getting a substring help plz

This is a discussion on Getting a substring help plz within the C Programming forums, part of the General Programming Boards category; My assignment is to get a substring from a string called *src. The substring may be chars, words, items, fields, ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    15

    Getting a substring help plz

    My assignment is to get a substring from a string called *src. The substring may be chars, words, items, fields, or records as determined by delims.


    First off, im not sure how to "get" a substring from another string. secondly, i know what a char is, but i dont know how to get words, items, or fields. Third, whats a delim?

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,169
    whats a delim?
    http://dictionary.reference.com/search?q=delimiter

    im not sure how to "get" a substring from another string.
    Look at the strstr(), strchr() and strcpy() functions.
    If you understand what you're doing, you're not learning anything.

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    You can use strstr and strtok but wouldn't the whole point to the assignment be to write your own functions?

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    24
    Im pretty new a c but i guess you would just write a function that would loop through the char array (string) copy a section of the array. Obviously you would have to pass the string(array), starting point and ending point to split from and the size of the array .(or you could just pass one endPoint and copy from the start of the string to that point).

    I actually always had trouble returning a string because its and array. Im sure theres ways round this but usually i pass the array im going to return to aswell and put the value in there in the function.

    ie. instead of
    string = StrSplit(SplitMeString,startingPoint,endingPoint,s ize);
    StrSplit(SplitMeString,startingPoint,endingPoint,s ize,string)
    Last edited by fatdunky; 11-01-2005 at 05:16 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can any1 plz make this assignment
    By jean in forum C Programming
    Replies: 17
    Last Post: 05-13-2009, 09:19 PM
  2. split string and remove substring
    By nyc_680 in forum C Programming
    Replies: 3
    Last Post: 03-02-2009, 03:45 AM
  3. I need help with creating a substring program
    By CProgramingBegg in forum C Programming
    Replies: 9
    Last Post: 02-06-2009, 08:50 AM
  4. Anyone plz help me
    By Rose_Flowers in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 09-17-2003, 12:01 PM
  5. help plz plz
    By nsssn73 in forum C++ Programming
    Replies: 2
    Last Post: 06-03-2002, 08:44 AM

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