<!-- Begin Anonymizer Control Bar --> <DIV ID="toolbar1" STYLE="visibility: show"> <SCRIPT LANGUAGE="JavaScript"> function openWin(URL) { var anonWindow=window.open(URL,"Subscribe_for_Services","height=320,resizable=no,toolbar=no,width=320"); anonWindow.focus(); }
>>245 charは整数型だよ‥‥ (規格書6.2.5) There are five standard signed integer types, designated as signed char, short int, int, long int, and long long int. ... For each of the signed integer types, there is a corresponding (but different) unsigned integer type (designated with the keyword unsigned) that uses the same amount of storage (including sign information) and has the same alignment requirements.
>>256 ひょっとして256=245? バイトの定義はあるよ。 addressable unit of data storage large enough to hold any member of the basic character set of the execution environment ビット数は決まってないけどね。
An integer character constant has type int. The value of an integer character constant containing a single character that maps to a member of the basic execution character set is the numerical value of the representation of the mapped character interpreted as an integer. ... EXAMPLE 2 Consider implementations that use two's- complement representation for integers and eight bits for objects that have type char. In an implementation in which type char has the same range of values as signed char, the integer character constant '\xFF' has the value -1; if type char has the same range of values as unsigned char, the character constant '\xFF' has the value +255 .
>>415 C は関数のためにその関数内で使われる変数などの情報を格納するためのスタックフレームというのを作成する (あいまいな言い方なので「スタックフレーム」をgoogleで検索してくれ) 関数Aから関数Bを呼んだとき、関数Bの処理が終了したら関数Aに戻るわけだが、 関数Aで宣言された変数などの情報をどこかに保存しないと 下の例でB()から帰ってきた後に変数 a の中身が消えてしまうという困ったことになる。
void A(){ int a, b, c; a = 1; b = B(); c = a + b; }
> 5.1.2.2.1 Program startup > 1 The function called at program startup is named main. The implementation declares no > prototype for this function. It shall be defined with a return type of int and with no > parameters: > > int main(void) { /* ... */ } > > or with two parameters (referred to here as argc and argv, though any names may be > used, as they are local to the function in which they are declared): > > int main(int argc, char *argv[]) { /* ... */ } > > or equivalent; or in some other implementation-defined manner.
で、 main文を繰り返してfunc内で func(){ printf("before %f\n",hoge); {処理} printf("after %f\n",hoge); } としてhogeの値を見てみると、 before 1.1 after 1.1 before 1.1 after 1.1 ・・・ と続くのですが、突然 before 1.1 after 1.1 before 1000.11 after 1000.11 みたいな感じで、hogeの値が変わってしまうのです。 こういう値がかわっちゃう現象は起こりうることなんでしょうか。 もしそうならその対処法みたいなものはあるのでしょうか。
/* a と b の最大公約数を求める */ int m, k, gcd; m = x > y ? y : x; for (k = 1; k < m; k++) if ((a % k == 0) && (b % k == 0)) gcd = k; /* ここで変数 gcd に a と b の最大公約数が入っている */