6

I know this is a very silly and simple question but I've been trying to print out an image of a robot that should output this:

+----------+
|          |
| /\    /\ |
| \/    \/ |
|          |
|  [-=-=-] |
+----------+

The part I'm stuck on is printing out the eyes. originally I coded:

printf("| /\  /\ |");
printf("| \/  \/ |");

but an error showed, so I remembered that you need to double slash so:

printf("| \/\\  \/\\ |");
printf("| \\\/  \\\/ |");

but an error saying implicit declaration of function printf is showing even after that?! I don't understand the error. Can someone explain how to fix this please?

George Cavalevu
  • 119
  • 1
  • 2
  • 6

2 Answers2

12

You don't need to escape forward slash.

This works for me:

#include <stdio.h>

int main()
{
  printf("| /\\  /\\ |");
  printf("| \\/  \\/ |");
  return 0;
}
Benjy Kessler
  • 7,356
  • 6
  • 41
  • 69
3

You have to use \ before backslash. Its separate the character.Like this

printf("| /\\  /\\ |\n");   
printf("| \\/  \\/ |"); 
Nils
  • 647
  • 6
  • 16