Sagar Pandya
Sagar Pandya

Reputation: 9497

Printing smiley face

This snippet is supposed to (according a textbook) print a 10 x 10 block of smiley faces.

#include <stdio.h>

int x, y;

int main( void )
{
   for ( x = 0; x < 10; x++, printf( "\n" ) )
       for ( y = 0; y < 10; y++ )
           printf( "%c", 1 );
  return 0;
}

Taken from Sams teach yourself C in one hour a day. All I'm getting is empty spaces (most probably a 10 x 10 block of spaces). How can I print a smiley face correctly?

I'm a using Cloud9 IDE workspace, which I believe creates a Linux environment.

Upvotes: 2

Views: 611

Answers (1)

Killian G.
Killian G.

Reputation: 380

You are trying to print the ascii value 1 which is SOH (start of heading)

If you want to print '1' try using printf("%c", '1');

Upvotes: 2

Related Questions