Thread: Ignoring most information from File.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    It looks like to me that all you need to do is parse line by line and look in between the pipe characters (|) for tokens. The strcspn() function makes tasks like that easy. Since the function returns the number of characters before a pipe was found, you can print or copy a string of exactly the right length. Try this in a loop:
    Code:
            tokenLength = strcspn(string, "|\n");
            printf("\t%.*s\n", (int)tokenLength, string);
    With some pointer arithmetic, you can get it done in a few more lines. You need to skip the delimiter (++string; ) and know when you've reached the end of the line you are parsing.

    Also note that ignoring input is basically reading input that you never used. You are going to have to slog through data that you don't need to get to what you do need. Count columns to realize where you are in relation to something useful on each line of data.

    I don't think magically slapping on wide characters is going to make the output look better, if that is still a problem. If the file is ANSI encoded there is no point in putting in more difficult code when a change of the command prompt window code page would make the output look correct. Does the OP even know the file's encoding?
    Last edited by whiteflags; 12-28-2014 at 11:10 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ignoring the stdio.h file in a c file
    By Raj 89 in forum C Programming
    Replies: 4
    Last Post: 11-28-2012, 11:08 AM
  2. removing/ignoring carrage returns from a file
    By katipo in forum C Programming
    Replies: 3
    Last Post: 12-01-2008, 03:55 PM
  3. Ignoring line in C++ when reading from file
    By falzone in forum C++ Programming
    Replies: 7
    Last Post: 11-16-2007, 12:08 AM
  4. File information in C
    By jakewendt in forum C Programming
    Replies: 2
    Last Post: 10-11-2002, 04:12 PM
  5. Ignoring a word from a .txt file
    By TrojanGekko in forum C++ Programming
    Replies: 1
    Last Post: 01-21-2002, 05:14 PM