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:
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.Code:tokenLength = strcspn(string, "|\n");
printf("\t%.*s\n", (int)tokenLength, string);
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?