7 Replies - 33837 Views - Last Post: 20 May 2006 - 11:36 PM Rate Topic: -----

#1 max302  Icon User is offline

  • Proud supporter of the lulz
  • member icon

Reputation: 2
  • View blog
  • Posts: 1,281
  • Joined: 05-March 06

Ascii art in c++

Posted 20 May 2006 - 02:41 PM

I've start some c++ without a book and I have run into my first problem. I want to spel the M in my name in old-skool ascii art, but when compiled, DEV-C++ gives me 26:8 H:\Fuel Calc 100.cpp [Warning] unknown escape sequence '\_'. So I figured out that like in html, some characters might be misinterpreted and appear like something totally different. My attempt to cout this:
	__	__   
	/\_\  /\_\	
   / /  |/ /  |  
  / /   | /   | 
 / / /| |/ /| |
 \/_/ |___/ |_|axime Rousseau


which looks much better in plaintext, the program gave me the image that i have included. Is there anyway of representing anti-slashes so they actually appear (like & special chars in html) ?

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Ascii art in c++

#2 frog  Icon User is offline

  • unleashed
  • member icon

Reputation: 2
  • View blog
  • Posts: 683
  • Joined: 26-March 06

Re: Ascii art in c++

Posted 20 May 2006 - 03:12 PM

what is it that you want to do ???didnt get what you are asking
Was This Post Helpful? 0
  • +
  • -

#3 max302  Icon User is offline

  • Proud supporter of the lulz
  • member icon

Reputation: 2
  • View blog
  • Posts: 1,281
  • Joined: 05-March 06

Re: Ascii art in c++

Posted 20 May 2006 - 03:18 PM

Anti slashes dont appear. I want to make them appear.
Was This Post Helpful? 0
  • +
  • -

#4 Mrafcho001  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 41
  • View blog
  • Posts: 769
  • Joined: 01-November 05

Re: Ascii art in c++

Posted 20 May 2006 - 03:29 PM

\ will always give an error.

you always do this when you want to print out the character '\'

cout << "\\" << endl; // prints out \


This post has been edited by Mrafcho001: 20 May 2006 - 03:30 PM

Was This Post Helpful? 0
  • +
  • -

#5 frog  Icon User is offline

  • unleashed
  • member icon

Reputation: 2
  • View blog
  • Posts: 683
  • Joined: 26-March 06

Re: Ascii art in c++

Posted 20 May 2006 - 03:36 PM

didnt realise that happened.well the ascii code for anti slash would be 92
you can use this statement to display it
cout<<(char)92;



but i dont no why does it not identify the anti slash
Was This Post Helpful? 0
  • +
  • -

#6 max302  Icon User is offline

  • Proud supporter of the lulz
  • member icon

Reputation: 2
  • View blog
  • Posts: 1,281
  • Joined: 05-March 06

Re: Ascii art in c++

Posted 20 May 2006 - 03:42 PM

View PostMrafcho001, on 20 May, 2006 - 02:21 PM, said:

\ will always give an error.

you always do this when you want to print out the character '\'

cout << "\\" << endl; // prints out \



Works fine now! thx a lot
Was This Post Helpful? 0
  • +
  • -

#7 Mrafcho001  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 41
  • View blog
  • Posts: 769
  • Joined: 01-November 05

Re: Ascii art in c++

Posted 20 May 2006 - 03:53 PM

\ in C++ is used like this:

cout << "This whole text \
will be on one line" << endl;
//Notice the difference between these 2 codes
cout << "This should give 
an error, rather than print on one line" << endl;

Was This Post Helpful? 0
  • +
  • -

#8 William_Wilson  Icon User is offline

  • lost in compilation
  • member icon

Reputation: 204
  • View blog
  • Posts: 4,807
  • Joined: 23-December 05

Re: Ascii art in c++

Posted 20 May 2006 - 11:36 PM

the forward slash or anti slash as you called it, is known as the esape character, meaning it escapes the normal usage of a letter etc, how \n is a new line, the \ escapes printing the n and interprets it differently, thus the only way to display \ character is to escape it as well, thus using \\

Your error occured, because there is no replacement for escaping a space, which occured often in your original code.

This post has been edited by William_Wilson: 20 May 2006 - 11:37 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1