ページ

2010年12月20日月曜日

[cui] [soft] コマンドプロンプトで暗号化・復号化ができるソフトを作ってみた。

このエントリーをはてなブックマークに追加

Code.zip download :
http://www21.atpages.jp/~lyrycal/download.html

・使い方についてはCode.zip内のreadMe.txtを参照してくだい。
・ウィルスチェックしてください。

by Raisana.

[curl] [cui] Windowsからcurlを使用する

このエントリーをはてなブックマークに追加

(i) http://curl.haxx.se/download.htmlからcurl-7.21.3.zipをdownload(12/20現在)

(ii) 解凍したcurl.exeをc:\curlに入れる

(iii) c:\curl;でパスを通す(スタート → コンピュータ  → システムのプロパティ → システムの詳細設定  → 詳細設定  → 環境変数  → システム環境変数のPathをダブルクリックして変数値c:\curl;を追加する)(vista/win7)

(iv) コマンドプロンプトを起動しcurlと入力する。成功すればcurl: try 'curl --help' or... と表示されます。

(v) curl -o lyrycalprogramming.html http://www21.atpages.jp/lyrycal/ のようにinput すればhtml形式のファイルがカレントディレクトリに保存される。(プロキシ環境では -x パラメータ追加すればダウンロードできます)

2010年10月28日木曜日

[C][VC++ 2010] strcmpの戻り値

このエントリーをはてなブックマークに追加

('A' < 'Z' < 'a' < 'z') = (0x41 < 0x5a < 0x61 < 0x7a)

// 2つの引数が同じ場合戻り値は 0
strcmp("A", "A") == 0

// 第一引数のほうが第二引数より小さければ戻り値は -1
strcmp("A", "B") == -1

// 第一引数のほうが第二引数より大きければ戻り値は 1
strcmp("B", "A") == 1


//==========================================
// 文字列の場合は頭から順に比較していきます。
//==========================================

// (i) A < E 先頭がこのような条件なので戻り値は -1
strcmp("ABC", "E") == -1

// (i) A == A, (ii) B == B, (iii) C < D ここで戻り値は -1 確定
strcmp("ABC", "ABD") == -1

// (i) A == A, (ii) B == B (iii) C == C, (iv) NULL < D ここで戻り値は -1 確定
strcmp("ABC", "ABCD") == -1

// (i) A < B, ここで戻り値は -1 確定
strcmp("ABC", "BCD") == -1

2010年10月27日水曜日

[C/C++]ポインタのポインタとポインタ配列

このエントリーをはてなブックマークに追加

//===============================================
// (i)
// iの領域がsizeof(int) * 10バイト
//===============================================
int * i;
i = (int *)malloc(sizeof(int) * 10);

*(i + 0) = 0;
*(i + 1) = 1;

free(i);



//===============================================
// (ii)
// iの要素の領域がsizeof(int)バイト
//===============================================
int ** i;

i = (int **)malloc(sizeof(int *) * 10);
for(int j = 0; j < 10; j++){
*(i + j) = (int *)malloc(sizeof(int));
}

*(*(i + 0)) = 0;
*(*(i + 1)) = 1;

for(int j = 9; j > 0; j--){
free(*(i + j));
}

free(i);



//===============================================
// (iii)
// iの要素の領域がsizeof(int)バイト
//===============================================
int * i[10];

for(int j = 0; j < 10; j++){
i[j] = (int *)malloc(sizeof(int));
}


*i[0] = 0;
*i[1] = 1;


for(int j = 9; j > 0; j--){
free(i[j]);
}



//===============================================
// (iv)
// strが(sizeof(int) + sizeof(int)) * 10 バイト
//===============================================
struct STR{
int x;
int y;
};

int main(){

STR * str;
str = (STR *)malloc(sizeof(STR) * 10);

(*(str + 0)).x = 0; (*(str + 0)).y = 0;
(*(str + 1)).x = 1; (*(str + 1)).y = 1;

free(str);

return 0;
}



//===============================================
// (v)
// strの要素が(sizeof(int) + sizeof(int)) バイト
//===============================================
struct STR{
int x;
int y;
};


int main(){

STR ** str;
str = (STR **)malloc(sizeof(STR *) * 10);
for(int j = 0; j < 10; j++){
*(str + j) = (STR *)malloc(sizeof(STR));
}

(*(str + 0))->x = 0; (*(str + 0))->y = 0;
(*(str + 1))->x = 1; (*(str + 1))->y = 1;

for(int j = 9; j > 0; j--){
free(*(str + j));
}
free(str);


return 0;
}



//===============================================
// (vi)
// strの要素が(sizeof(int) + sizeof(int)) バイト
//===============================================

struct STR{
int x;
int y;
};


int main(){

STR * str[10];
for(int j = 0; j < 10; j++){
str[j] = (STR *)malloc(sizeof(STR));
}

str[0]->x = 0; str[0]->y = 0;
str[1]->x = 1; str[1]->y = 1;

for(int j = 9; j > 0; j--){
free(str[j]);
}

return 0;
}

2010年10月22日金曜日

[C/C++] 三次元 ポインタ

このエントリーをはてなブックマークに追加

#include<iostream>


int main(){

int *** ary_p;

ary_p = (int ***)malloc(sizeof(int **) * 3);
for(int i = 0; i < 3; i++){
ary_p[i] = (int **)malloc(sizeof(int *) * 3);
}
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
ary_p[i][j] = (int *)malloc(sizeof(int) * 3);
}
}

for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
for(int p = 0; p < 3; p++){
*(*(*(ary_p+i)+j)+p) = p + i + j;
std::cout << *(*(*(ary_p+i)+j)+p) << "\n";
}
}
}

return 0;
}

2010年8月29日日曜日

[Google Go] 2.Hello Go World

このエントリーをはてなブックマークに追加

//==============================================
// hello.go (source)
//==============================================

package main
import "fmt"

func main(){
fmt.Printf("Hello Go World\n")
/* comment */
// comment
}

//==============================================
// compile (6g for x86 64bit)
//==============================================
6g hello.go
6l -o hello hello.6
./hello

//==============================================
// compile (8g for x86 32bit)
//==============================================
8g hello.go
8l -o hello hello.6
./hello

1.このプログラムではターミナルにHello Go Worldと出力されます。
2.fmt.Printfを使用するためにfmt packageをインポートしています。他の機能を使用したい場合は他のパッケージをインポートします。
3.funcというキーワードで関数を導入します。
4.main関数はいくつかの初期化の後に走り始めます。
5.Go言語のソースファイルはUTF-8(BOMなし)でエンコードするように定義されている。
6.注釈の取り決めはC++と同じです。
/* hoge hoge */
// hoge hoge
7.コンパイルはx86 64bit版のための6g, x86 32版のための8gがあります。

[Google Go] 1.Introduction

このエントリーをはてなブックマークに追加

[重要]
1.golang.orgに基づいて記載していきます。
2.Go言語についての3日間コースのPDF → Day1, Day2, Day3
3.Go言語の控えめなソースコード /doc/progs/

[注意]
1.windows環境はお勧めしません。(使用できないPackageが存在する)

[raisanaの実行環境]
Ubuntu 10.04