6

I want to print the following in C.

Tonight’s schedule is:
•   Pizza
•   Movie
•   ice cream

I do not know how to print the bullet point character.

Peter Badida
  • 11,310
  • 10
  • 44
  • 90
F.leon
  • 81
  • 1
  • 2
  • Please see http://www.fileformat.info/info/unicode/char/2022/index.htm – Sabik Jul 13 '16 at 12:40
  • 2
    Possible duplicate of [how to print non-ASCII characters in C](http://stackoverflow.com/questions/13050899/how-to-print-non-ascii-characters-in-c) – jwpfox Jul 13 '16 at 12:40
  • Possible duplicate of [How to print "box drawers" Unicode characters in C (Linux utf8 terminal)?](http://stackoverflow.com/questions/14430899/how-to-print-box-drawers-unicode-characters-in-c-linux-utf8-terminal) – Karl Nicoll Jul 13 '16 at 12:51
  • 1
    `printf("\u2022Pizza\u2022Movie\u2022ice cream\n");` is what you're looking for. – sjsam Jul 13 '16 at 12:51
  • C does not provide any special functions for that. What is your console capable of? – Jongware Jul 13 '16 at 13:28

6 Answers6

4

The code bellow can give you guide on this:

#include <stdio.h>

int main(int argc, char** argv)
{
  printf("Tonight’s schedule is: \u2022 Pizza \u2022 Movie \u2022 ice cream\n");
  return 0;
}
sel-fish
  • 4,308
  • 2
  • 20
  • 39
  • Technically, that apostrophe should be `\u`-encoded or replaced with an ASCII `'`. Probably just the OP's browser replacing the character and you copied it, but this example might do something weird at the `’` if someone copies and pastes it. – yellowantphil Jul 13 '16 at 22:46
2

• search for html number &#8226; This link declares "\u2022" as the C source code encoding.

AsheraH
  • 474
  • 10
  • 15
  • 1
    Note, that compiler expands `\u2022` to UTF-8 encoded data: `"Tonight\342\200\231s schedule is: \342\200\242 Pizza \342\200\242 Movie \342\200\242 ice cream"`. And probably old compilers doesn't understand \u notation, so you should encode it by yourself. – Sergio Jul 13 '16 at 13:10
  • @Serhio that expansion is compiler-dependent – M.M Jul 13 '16 at 13:40
  • @M.M You're right. At least it should be the most popular approach. – Sergio Jul 13 '16 at 13:44
1

You can simply do this:-

puts("Tonight’s schedule is: • Pizza • Movie • ice cream");
tryKuldeepTanwar
  • 3,490
  • 2
  • 19
  • 49
  • 1
    Output on a Win7 machine with English(Aus) as the language: `TonightÔÇÖs schedule is: ÔÇó Pizza ÔÇó Movie ÔÇó ice cream` – enhzflep Jul 13 '16 at 13:43
  • 1
    Maybe you need English(United States) as the language because its working perfect for me on window7 machine. @enhzflep – tryKuldeepTanwar Jul 13 '16 at 13:47
  • Thanks for the suggestion, I'll give it a try. – enhzflep Jul 13 '16 at 13:49
  • 1
    It very much depends on the character set of the C source file, the character set the compiler assumes when compiling the source file, any conversions done by the text mode stream, and any conversions done by the host environment (including the terminal) on the emitted output bytes. – Ian Abbott Jul 13 '16 at 14:18
  • hey if you find the answer helpful don't forget to mark it right. – tryKuldeepTanwar Jul 14 '16 at 03:38
1

You can do it using Extended ASCII values.If you run your program in cmd, sometimes this will not work. because your cmd code page doesn't support for those ASCII values. paste this code in to the codechef online ide(https://www.codechef.com/ide) and run it and see the out put. This is a working solution.

#include <iostream>
using namespace std;

#include<stdio.h>



int main(){

    char list1[]="Pizza";
    char list2[]="Movie";
    char list3[]="ice cream";
    int a=149;


   printf("%c %s %c %s %c %s",a,list1,a,list2,a,list3);



}
dulaj sanjaya
  • 1,290
  • 13
  • 25
  • 3
    149 is not an ASCII value: the highest ASCII character is 127. But what you propose could work on Windows, if you're using [Windows-1252](https://en.wikipedia.org/wiki/Windows-1252) or a similar encoding. (Also, you don't need to give the size of the arrays when declaring them and initializing them the way you did. The compiler will figure out the length.) – yellowantphil Jul 13 '16 at 16:26
  • Yes I agree with you. I will fix it – dulaj sanjaya Jul 13 '16 at 16:36
1

it depends on the terminal where you want the characters to be shown. Send the characters according to the enconding of this terminal. For example, it is different for MS-windows (using, for example windows 1252) or linux (using, for example utf-8).

EFenix
  • 831
  • 4
  • 11
-1

This is the conversion of ascii to character.

#include<stdio.h>
void main(){
   char a=atoi("149");
   printf("%c %s %c %s %c %s",a,"pizza",a,"movie",a,"ice cream");   
}
Jees K Denny
  • 531
  • 5
  • 27