How to substring ?

This is a discussion on How to substring ? within the C Programming forums, part of the General Programming Boards category; Hi All, Does anyone know, how to substring a set of characters given the start and end positions ? I ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    1

    Question How to substring ?

    Hi All,

    Does anyone know, how to substring a set of characters
    given the start and end positions ?

    I am trying to cut a long string into chunks of 250
    characters and store them in an array.

    Thanks in advance.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,663
    Code:
    char buff[100][251];
    for ( i = 0, j = 0 ; i < n ; i += 250, j++ ) {
      strncpy( buff[j], &line[i], 250 );
      buff[j][250] = '\0';
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. split string and remove substring
    By nyc_680 in forum C Programming
    Replies: 3
    Last Post: 03-02-2009, 03:45 AM
  2. I need help with creating a substring program
    By CProgramingBegg in forum C Programming
    Replies: 9
    Last Post: 02-06-2009, 08:50 AM
  3. longest common substring problem
    By Enchanter88 in forum C++ Programming
    Replies: 4
    Last Post: 09-29-2007, 11:02 AM
  4. Replies: 11
    Last Post: 12-11-2005, 10:50 PM
  5. Getting a substring help plz
    By joshua in forum C Programming
    Replies: 3
    Last Post: 11-01-2005, 05:11 PM

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