2012年3月16日金曜日

開発環境

『実践プログラミング 第3版』 (Steve Oualline (著)、 望月 康司 (監修) (翻訳)、 谷口 功 (翻訳)、 オライリー・ジャパン、1998年、ISBN978-4900900646)の4章(基本的な宣言および式)(プログラミング実習)4.3(プログラミング実習4-4, 5を解いてみる。

4-4.

コード(TextWrangler)

#include<stdio.h>

int main(){
  printf("*   * ***** *     *       *  \n");
  printf("*   * *     *     *     *   *\n");
  printf("*   * *     *     *     *   *\n");
  printf("***** ***** *     *     *   *\n");
  printf("*   * *     *     *     *   *\n");
  printf("*   * *     *     *     *   *\n");
  printf("*   * ***** ***** *****   *  \n");
  
  return (0);
}

入出力結果(Terminal)

$ cc -g -o c_program c_program.c
$ ./c_program
*   * ***** *     *       *  
*   * *     *     *     *   *
*   * *     *     *     *   *
***** ***** *     *     *   *
*   * *     *     *     *   *
*   * *     *     *     *   *
*   * ***** ***** *****   *  
$

4-5.

コード(TextWrangler)

#include<stdio.h>

float a;
int main(){
 a = 1.2;
 printf("%d\n",a);
 return (0);
}

入出力結果(Terminal)

$ cc -g -o c_program c_program.c
c_program.c: In function ‘main’:
c_program.c:6: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘double’
c_program.c:6: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘double’
$ ./c_program
1817385768
$

コード(TextWrangler)

#include<stdio.h>

int a;
int main(){
 a = 10;
 printf("%f\n",a);
 return (0);
}

入出力結果(Terminal)

$ cc -g -o c_program c_program.c
c_program.c: In function ‘main’:
c_program.c:6: warning: format ‘%f’ expects type ‘double’, but argument 2 has type ‘int’
c_program.c:6: warning: format ‘%f’ expects type ‘double’, but argument 2 has type ‘int’
$ ./c_program
0.000000
$

コード(TextWrangler)

#include<stdio.h>

char a;
int main(){
 a = 'k';
 printf("%d\n",a);
 return (0);
}

入出力結果(Terminal)

$ cc -g -o c_program c_program.c
$ ./c_program
107
$
  1. %d変換を使って浮動小数点数を出力する
  2. %f変換を使って整数型を出力する
  3. %d変換を使って文字型を出力する

の3つとも警告が出ると思ったら、3つ目だけ警告がでなかった。

出力結果は意図とは違うけど3つともプログラムをコンパイルして実行までできた。

1 コメント :

Unknownさんのコメント...

It was subsequently alarming during the time a new steel pursuit sit back and watch which usually offered in the comparable expense like a keep an eye on out of other sorts of brandnames. The particular parallel amongst the automobile watching can be amusing, as well as quantities will be almost exactly the same every. Regretably, typically the amazing performance to a look at who was blisteringly extremely fast, and also ultra gorgeous, achieved the country demise. Your timepieces absolutely failed to! It was eventually and so stunning not to mention tasteful. This became a wrist watch meant to be a good iconic reflection from the trademark. When most people imagined the particular keep an eye on has been gorgeous, merely a few consumers quite grasped the significance in its structure, as well as the significant firm in back of the idea. Rapid in advance to help 2015. the designer watches have been in type include before and even ceramic could be the most popular material all around. The industry is definitely heaped with wristwatches made of plastic, sheet metal and also inflated metal. Your timepieces cardio possesses tried using different products along with such as a great many others favors ceramic for a few software programs even though wholly ceramic watches are nevertheless extraordinary. Since rewards of the very most 1st view, they have already developed on an original composition generating a large number of kinds and even wraps up in which extends their accomplish in the economy whereas staying valid in their primary vision- an extravagance outdoor activity watch out for quite a scary user. The standard keep an eye on continues to be grew so that you can contain a tourbillion, a chronograph, some sort of perpetual appointments, some grand end result, plus much more! www.refinedwatch.com. Wedding reception receive a view absolutely dealt with around jewels any time that is ones element. Selecting for a loving or even possibly not, this follow is often ready to attempt an item innovative, impressive and even striking. Speaking of dimensions, I enjoy your watch in which gives in 48mm diverse, nonetheless alas Ariel undoubtedly reviewed it again, therefore i california not even. Equally, We can solely that is amazing any necklace supplied a bit of a break from convention with the thing that was around, in the case of active rings on the market. In addition to, when you have gotten any necklace altered accordingly, it must be comfy in just about any arm.

コメントを投稿