LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-28-2011, 11:05 PM   #1
Shao Lung
Member
 
Registered: Apr 2011
Posts: 71

Rep: Reputation: 0
unknown escape sequence


I am practicing my C and in one of my lines i have this

Code:
 printf("\/");
how do I get to use \ to print out?
thanks in advance
 
Old 04-28-2011, 11:30 PM   #2
rocket357
Member
 
Registered: Mar 2007
Location: 127.0.0.1
Distribution: OpenBSD-CURRENT
Posts: 485
Blog Entries: 187

Rep: Reputation: 74
Not sure I understand the question, but here:

Code:
$ cat test.c
#include <stdio.h>

int main() {
        printf("\\   \n");
        printf("/    \n");
        printf("\\/  \n");
        return 0;
}
$ cc test.c -o printf_test
$ ./printf_test
\
/
\/
$
Since \ is the beginning of an escape sequence (i.e. "\n" for newline, "\t" for tab, etc...), you have to "escape the escape", or "\\".

Last edited by rocket357; 04-28-2011 at 11:35 PM.
 
1 members found this post helpful.
Old 04-28-2011, 11:38 PM   #3
Shao Lung
Member
 
Registered: Apr 2011
Posts: 71

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rocket357 View Post
Not sure I understand the question, but here:

Code:
$ cat test.c
#include <stdio.h>

int main() {
        printf("\\   \n");
        printf("/    \n");
        printf("\\/  \n");
        return 0;
}
$ cc test.c -o printf_test
$ ./printf_test
\
/
\/
$
Since \ is the beginning of an escape sequence (i.e. "\n" for newline, "\t" for tab, etc...), you have to "escape the escape", or "\\".
thanks that fixed it,,, now my printf will print to the screen \/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Any way to disable the escape sequence with "screen"? slinx Linux - General 2 01-06-2010 09:04 AM
unknown escape sequence: '\040' jiikka Linux - General 1 03-09-2009 07:48 AM
escape sequence help in C name_in_use450 Linux - General 6 07-01-2004 09:23 AM
escape sequence for changing color of prompt killer_bunny Linux - General 1 02-10-2004 07:40 PM
smiley face escape sequence problem mandrakeroot Programming 12 09-06-2003 06:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration