Thread: while reading a text, how to find the asicii control characters and then display them

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    4

    Arrow while reading a text, how to find the asicii control characters and then display them

    this will run just like "cat -v filename"

    if there is some control characters in the filename, such like control A, control B...

    normal these control characters is not able to print out, but after program, they can be print out..


    my point is, i dont know how to separate control characters with other normal character, and then how can i make is displayable..??
    i tried to use iscotrl() to check the control character, but it cant separate '\n' with control characters...

    anyway, thx for help

    regards

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Assuming ascii, how about
    Code:
    if (c < ' ' && c != '\n') { /* add  && c != '\t' if you don't want tabs either */
        printf("^%c", c + ('A' - 1));
    }
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    4
    is it? thats nice.. thx ogaga

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by yang View Post
    normal these control characters is not able to print out,
    ctype.h, isprint()


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Registered User
    Join Date
    Mar 2012
    Posts
    4
    i tried it, !isprint() is same as < ' '

    thx~

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 09-23-2011, 04:07 PM
  2. Reading plain text into a RichEdit control
    By JustMax in forum C Programming
    Replies: 0
    Last Post: 02-03-2009, 03:15 PM
  3. display icon in tree control
    By sgh in forum Windows Programming
    Replies: 0
    Last Post: 04-30-2008, 08:54 AM
  4. Type text = Press button = Display text in Google?
    By Raze88 in forum C++ Programming
    Replies: 4
    Last Post: 03-20-2008, 08:39 AM
  5. Inconsistent display of tab characters in edit control
    By New++ in forum Windows Programming
    Replies: 0
    Last Post: 01-06-2006, 08:34 AM