Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6607283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:29:13+00:00 2026-05-25T19:29:13+00:00

That is, prt(a \t\n) should print a \t\n literally, is there any available function

  • 0

That is, prt("a \t\n") should print "a \t\n" literally,

is there any available function that does this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:29:14+00:00Added an answer on May 25, 2026 at 7:29 pm

    I am assuming you want to escape special characters; that is, you want to print \n instead of a newline character.

    Not in the standard library, as far as I know. You can easily write it yourself; the core of the function is something like this:

    static char *escape_char(char *buf, const char *s) {
        switch (*s) {
            case '\n': return "\\n";
            case '\t': return "\\t";
            case '\'': return "\\\'";
            case '\"': return "\\\"";
            case '\\': return "\\\\";
            /* ... some more ... */
            default:
                buf[0] = *s;
                buf[1] = '\0';
                return buf;
        }
    }
    
    /* Warning: no safety checks -- buf MUST be long enough */
    char *escape_string(char *buf, const char *s)
    {
        char buf2[2];
        buf[0] = '\0';
        for (; *s != '\0'; s++) {
            strcat(buf, escape_char(buf2, s));
        }
        return buf;
    }
    

    Generating the function body is also an option, as it can get quite tedious and repetitive.

    This is how you can test it:

    int main()
    {
        const char *orig = "Hello,\t\"baby\"\nIt\'s me.";
        char escaped[100];
        puts(orig);
        puts(escape_string(escaped, orig));
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That is, is there an embedded R interpreter available?
That should be simple web site but with an editable tree. This tree will
That's it. If you want to document a function or a class, you put
That's basically the question, is there a right way to implement operator<< ? Reading
That may sound a little confusing. Basically, I have a function CCard newCard() {
that's the problem.. This is a simplified version of what i would like do:
i am trying to compile this code, but if i do using: gcc prt.c
What I'm doing exactly is this: I have a class Welcome that calls another
That sounds familiar I'm sure, but it's not a CSS hack issue. I'm literally
That's a simple question: is there an API to draw a B-tree in Java?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.