Thread: Reading the data bitween the different headers in a buffer.

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    1

    Reading the data bitween the different headers in a buffer.

    Hi All,

    I have to read the data bitween the headers in a buffer as below mentioned

    char Char_Frame[1400]="123456789 C|A|abcd efghijklm|E|";

    I am receiving the data form CPU COM1, the data is copied in Char_Frame (above mentioned) i have to read the data bitween C|A| and |E|. These header come at any times within the size of that buffer. I have to read the data bitween those headers and send to the server. Could you please give me the logic to implement this.



    Thanks,
    Arise

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I am sooooooo tempted to write PERL code to reply to a user again (especially since this one is easiest to handle in PERL).

    Example:
    Code:
    char *delim1 = strstr(Char_Frame, "|A|");
    char *delim2 = strstr(delim, "|E|");    // though careful with this guy... since the above could
                                                              // have returned NULL.
    
    char temp[256];
    
    memcpy(temp, delim1 + 3, (delim2 - delim1) - 6)
    As opposed to one statement in PERL... but who is counting anyway.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading data from buffer using pointers
    By carrotcake1029 in forum C Programming
    Replies: 3
    Last Post: 07-18-2008, 05:47 PM
  2. Reading data from a text file
    By Dark_Phoenix in forum C++ Programming
    Replies: 8
    Last Post: 06-30-2008, 02:30 PM
  3. reading in file data
    By sickofc in forum C Programming
    Replies: 2
    Last Post: 03-01-2006, 05:16 PM
  4. Reading a line of data...
    By RedZippo in forum C++ Programming
    Replies: 10
    Last Post: 04-04-2004, 02:14 AM
  5. EOF reading in the buffer
    By SuperNewbie in forum Windows Programming
    Replies: 1
    Last Post: 12-17-2003, 07:07 AM