Thread: Splitting An Array

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    1

    Splitting An Array

    Hi,

    I'm writing a program that will do what the UNIX cut command does. I've written the code to read in the ranges, and to open a file for reading.

    I have two seperate char arrays which hold the ranges for -c and -f.
    For example, cranges holds
    Code:
    {'1', '-', '3', ',', '4',  ',', '5', '-'};
    Each range is delimited by a comma.
    I have written a function which takes a range and returns an integer depending on what type it is:
    N
    N-M
    N-
    -N

    I'm wondering how to best take each range and pass it into my get_range function. I was trying to tokenize the array, but that just crashes my program.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Can you show an example of what you want, with one array? All the way through it?

    I can't tell if you need the values you want, from the array, or the index to the values you want in the array. I can't even tell if your program needs to take this "cut".

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  3. Splitting stream of bytes into block of array.
    By gravityzer0 in forum C Programming
    Replies: 7
    Last Post: 08-22-2006, 06:27 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM