2014年1月18日土曜日

開発環境

Head First C ―頭とからだで覚えるCの基本(David Griffiths (著)、Dawn Griffiths (著) 中田 秀基(監訳)(翻訳)、木下 哲也 (翻訳)、オライリージャパン)の2章(メモリとポインタ)、コンパスマグネット(p.49)を解いてみる。

その他参考書籍

コンパスマグネット(p.49)

コード

sample.c

#include <stdio.h>

void go_south_east(int * lat, int * lon)
{
    *lat = *lat - 1;
    *lon = *lon - 1;
}

int main()
{
    int latitude = 32;
    int longitude = -64;
    
    go_south_east(&latitude, &longitude);
    printf("停止!現在位置: [%i, %i]\n", latitude, longitude);
    return (0);
}

入出力結果(Terminal)

$ cc -g -o sample sample.c && ./sample
停止!現在位置: [31, -65]
$

0 コメント:

コメントを投稿