Cのメモリー割り当て

/**************プログラミング概要*******************/
/**********Cはメモリーをどう使うか**************/

/*アドレスの表示*/
function1のアドレスは'00401150' ⇒関数function1( )のアドレス
function2のアドレスは'0040117A' ⇒関数function2( )のアドレス
文字数リテラルのアドレスは'0040A20E' ⇒文字数リテラル
function1_static_variableのアドレスは'0040C5BC' ⇒関数function1内のstatic変数
function2_static_variableのアドレスは'0040C5C0' ⇒関数function2内のstatic変数
file_static_variable(グローバル変数)のアドレスは'0040C5C8' ⇒ファイル内のstatic変数
global_variable(グローバル変数)のアドレスは'0040C5C4' ⇒グローバル変数
mallocのアドレスは'012F2A60' ⇒malloc( )により確保された領域
function1_variableのアドレスは'0012FF44' ⇒function1( )での自動変数
function2_variableのアドレスは'0012FF44' ⇒function2( )での自動変数

#include<stdio.h>
#include<stdlib.h>

int global_variable;
static file_static_variable;

void function1( )
{
int function1_variable;
static int function1_static_variable;

printf("function1_variableのアドレスは%p\n",&function1_variable);

printf("function1_static_variableのアドレスは%p\n",&function1_static_variable);
}

void function2( )
{
int function2_variable;
static int function2_static_variable;

printf("function2_variableのアドレスは%p\n",&function2_variable); 

printf("function2_static_variableのアドレスは%p\n",&function2_static_variable);
}

int main_foejls(void)
{
int *p;
//関数へのポインタ表示
printf("function1のアドレスは%p\n",function1);

printf("function2のアドレスは%p\n",function2);

printf("文字数リテラルのアドレスは%p\n","abc");

printf("global_variable(グローバル変数)のアドレスは%p\n",&global_variable);

//ファイル内static変数のアドレス表示
printf("file_static_variable(グローバル変数)のアドレスは%p\n",&file_static_variable);

//ローカル変数の表示
function1( );

function2( );

//mallocにより確保した領域のアドレス
p=malloc(sizeof(int));
printf("mallocのアドレスは%p\n",p);

return 0;
}

演算子と型変換

今日はこれをやった。型変換するためのキャストと変数をうまく使い回すための練習。コンパイルが通らないため、いらいらすることが多くなる。
/**************プログラミング概要*******************/
/************int型の変数をdouble型の変数に代入*********************/
#include<stdio.h>

int main_dieiki(void)
{
int int_kata_suuji;
double double_kata_suuji;

int_kata_suuji=160;

printf("身長は%dセンチです\n",int_kata_suuji);

printf("double型の変数に代入します\n");

double_kata_suuji=int_kata_suuji; //int型の変数をdouble型の変数に代入した

printf("身長は%fセンチです\n",double_kata_suuji);

return 0;
}

#include<stdio.h>

int main_daljla(void)
{
  int takasa,teihen;
double menseki;

printf("三角形の高さを入力しなさい\n");
scanf("%d",&takasa);

printf("三角形の底辺を入力しなさい\n");
scanf("%d",&teihen);

menseki=(double)(takasa*teihen)/2; //cast演算子を用いて、int型演算を実数型演算に変換

printf("三角形の面積は%fです\n",menseki);

return 0;
}

#include<stdio.h>

int main_dkkjk(void)
{

int kazu=0;

printf("整数を入力してください\n");

scanf("%d",&kazu);

kazu=kazu*-1;

printf("正負を反転すると%dです\n",kazu);

return 0;
}


#include<stdio.h>

int main(void)
{
int kazu_1,kazu_2,kazu_3,kazu_4,kazu_5;
double karinoiremono;

karinoiremono=0-4;

printf("0-4=%d\n",karinoiremono);

karinoiremono=3.14*2;

printf("3.14*2=%.3lf\n",karinoiremono);

karinoiremono=5/3.0;

printf("5/3=%.3lf\n",karinoiremono);

karinoiremono=30%7;

printf("30%7=%lf\n",karinoiremono);

karinoiremono=(7+32)/5;

printf("(7+32)/5=%.1lf\n",karinoiremono);


return 0;
}

#include<stdio.h>

int main_finito(void)
{
int hennonagasa,menseki;

printf("正方形の辺の長さを整数で入力してください\n");

scanf("%d",&hennonagasa);

menseki=hennonagasa*hennonagasa;

printf("正方形の面積は%d\n",menseki);

return 0;
}

#include<stdio.h>

int main(void)
{
int kamoku_1,kamoku_2,kamoku_3,kamoku_4,kamoku_5;//代入されるから、初期化いらない
int goukei=0;   //参照する必要があるため、初期化がする必要
double heikin;//goukeiはint型のほうがいい。代入されるから、初期化いらない

printf("科目1の点数を入力してください\n");
scanf("%d",&kamoku_1);

printf("科目2の点数を入力してください\n");
scanf("%d",&kamoku_2);

printf("科目3の点数を入力してください\n");
scanf("%d",&kamoku_3);

printf("科目4の点数を入力してください\n");
scanf("%d",&kamoku_4);

printf("科目5の点数を入力してください\n");
scanf("%d",&kamoku_5);

goukei= kamoku_1+kamoku_2+kamoku_3+kamoku_4+kamoku_5;

printf("5科目の合計点は%d点です\n",goukei);

heikin=(double)goukei/5;
printf("5科目の平均点は%lf.2点です\n",heikin);

return 0;
}

/**************プログラミング概要*******************/
/************double型変数にint型変数を代入(無理がある)*********************/
#include<stdio.h>
int main_ndjk(void)
{
int int_kata_suuji;
double double_kata_suuji;

double_kata_suuji=160.5;

printf("身長は%fセンチです",double_kata_suuji);

printf("int型の変数に代入する\n");

int_kata_suuji=double_kata_suuji; //double型変数にint型変数を代入した

printf("身長は%dセンチです\n",int_kata_suuji);//バイト数が不足し、データが漏れる

return 0;
}

#include<stdio.h>

int main_lkjlkfj(void)
{
int d=2;
double pi=3.14;

printf("直径が%dセンチの円の\n",d);
printf("円周は%fセンチです\n",d*pi); //d*piの解は大きい型のdouble型に変換される

return 0;
}

/**************プログラミング概要*******************/
/*************int型同士の演算には注意が必要********************/
#include<stdio.h>

int main_wed(void)
{
int kazu1,kazu2;
double kotae;

kazu1=5;
kazu2=4;

kotae=kazu1/kazu2; //kazu1/kazu2の演算はint型同士の演算
                      //kotae=(double)kazu1/kazu2を使えば問題解決
printf("5/4は%.3fです\n",kotae); // kotaeにはInt型の演算結果が代入されている

return 0;
}

式と演算(operator,operand)

変数を用意して、四則演算子を使って、加減乗除させる。
それほど、難しくはなさそう。
/**************プログラミング概要*******************/
/*************定数で式と演算********************/
#include<stdio.h>

int main_pooeiik(void)
{
printf("1+2は%dです。\n",1+2);
printf("3×4は%dです。\n",3*4);

return 0;
}
/**************プログラミング概要*******************/
/****************式と演算*****************/
#include<stdio.h>

int main_addlk(void)
{
int suuchi1=2;
int suuchi2=3;
int goukei;
goukei=suuchi1+suuchi2;

printf("変数suuchi1の値は%dです。\n",suuchi1);
printf("変数suuchi2の値は%dです。\n",suuchi2);
printf("suuchi1+suuchi2の合計は%dです。\n",goukei);

suuchi1=suuchi1+1;  //ここが重要
printf("変数suuchi1の値に1を足すと%dです。\n",suuchi1);

return 0;
}

/**************プログラミング概要*******************/
/***************2変数で式の演算をする******************/
#include<stdio.h>

int main_nfjjsd(void)
{
int seisuu1,seisuu2;

printf("整数1を入力してください。\n");

scanf("%d",&seisuu1);

printf("整数2を入力してください。\n");
scanf("%d",&seisuu2);

//  ,seisuu1+seisuu2がミソ
printf("2つの整数の足し算の結果は%dです。\n",seisuu1+seisuu2);

return 0;
}

/**************プログラミング概要*******************/
/*****************定義して演算****************/
#include<stdio.h>

int main_klkfklj(void)
{
char kubun;
int tanka,suuryou; //2変数を宣言して、最後のprintf文で演算した

//goukei=tanka+suuryou;のやり方もある。

printf("区分を入力してください。\n");
scanf("%c",&kubun);

printf("単価を入力してください。\n");
scanf("%d",&tanka);


printf("数量を入力してください。\n");
scanf("%d",&suuryou);

printf("区分%cで合計は\\%dです。\n",kubun,tanka*suuryou);
return 0;
}
/**************プログラミング概要*******************/
/*********************************/
#include<stdio.h>

int main_ghhhh(void)
{
int kazu1=10;
int kazu2=5;

printf("kazu1とkazu2に色々な演算を行う。\n");
printf("kazu1+kazu2は%dです\n",kazu1+kazu2);
printf("kazu1-kazu2は%dです\n",kazu1-kazu2);
printf("kazu1*kazu2は%dです\n",kazu1*kazu2);
printf("kazu1/kazu2は%dです\n",kazu1/kazu2);
printf("kazu1%%kazu2は%dです\n",kazu1%kazu2);

return 0;
}


/**************プログラミング概要*******************/
/*************5つの変数で演算********************/
int main_irej(void)
{
int suuchi1,suuchi2;
int total1,total2;
int goukei;

printf("数値1を入力してください\n");
scanf("%d",&suuchi1);

printf("数値2を入力してください\n");
scanf("%d",&suuchi2);

goukei=suuchi1+suuchi2;  //goukeiに加算の演算結果を格納
printf("数値1と数値2の合計は%dです\n",goukei);

total1=goukei*suuchi2;  //goukeiに加算の演算結果を格納
printf("合計にを数値1で乗算した値は%dです\n",total1);

total2=goukei%suuchi2; //goukeiに加算の演算結果を格納
printf("合計を数値2で剰余した値は%dです\n",total2);

return 0;
}

getchar()

getchar()の使い方が分かり難い。一文字の入力のみ受け取るのはscanfと同じようだが、別の変数を用意しておいて、それに代入してやる? ffluch(stdin)何のことやら。

/**************プログラミング概要*******************/
/****************getcharを使って英数字を一つ入力させる*****************/
#include<stdio.h>
int main(void)
{
char eisuuji;//char型の宣言

printf("文字を入力してください(英数字)\n");
eisuuji=getchar();//プロンプト画面から入力させる
printf("%cが入力されました\n",eisuuji);//結果

fflush(stdin);/********fflush(stdin)でcharを空にしてgetcharのバグを解消***********/
eisuuji=getchar();//プロンプト画面から入力させる
printf("%cが入力されました\n",eisuuji);//結果

fflush(stdin);/*******************/
eisuuji=getchar();//プロンプト画面から入力させる
printf("%cが入力されました\n",eisuuji);//結果

return 0;
}

変数宣言と入出力(printf,scanf)

int型や、double型、char型を宣言して、scanf関数で入力させ、printfで出力させるプログラムを組む練習をした。
難しいのは、int→"%d"、double→"%f"、char→"%c"といったように変数の型に合わせて、変換使用を合致させなければいけない点。あと、scanfの引数には&(アンパーサンド)を付けて、printfでは、必要がないこと。単純そうだが、これがうまく対応せず、コンパイルエラーの連発だった。

include<stdio.h>
int main_lesson1(void)
{
   int age;

   printf("あなたは何歳ですか?\n");
   scanf("%d",&age);

   printf("あなたは%d歳です。\n",age);

  return 0;
}

/**************プログラミング練習*******************/

#include<stdio.h>
int main_lesson2(void)
{
 double ennshuuritu;

 printf("円周率の値はいくつですか?\n");
 scanf("%lf",&ennshuuritu);

 printf("円周率の値は%lfです。\n",ennshuuritu);

 return 0;
}

/**************プログラミング練習*******************/

#include<stdio.h>
int main_lesson3(void)
{
 char alpha;

 printf("アルファベットの最初の文字はなんですか?\n");
 scanf("%c",&alpha);

 printf("アルファベットの最初の文字%cです。\n",alpha);

 return 0;
}

/**************プログラミング練習*******************/

#include<stdio.h>
int main_lesson4(void)
{
  double sinchou,taijyuu;

 printf("身長を入力してください。\n");
 scanf("%lf",&sinchou);

 printf("体重を入力してください。\n");
 scanf("%lf",&taijyuu);

 printf("身長は%lfセンチです。\n",sinchou);
 printf("体重は%lfキログラムです。\n",taijyuu);

return 0;
}
/**************プログラミング概要*******************/
#include<stdio.h>

int main_finitto(void)
{
 int InumA,InumB; //int型の2変数を宣言
 double Dnum; //double型の変数宣言

 printf("int型の値を入力してください\n");
 scanf("%d",&InumA);

 printf("num型の値を入力してください\n");
 scanf("%lf",&Dnum);

 printf("int型の値を入力してください\n");
 scanf("%d",&InumB);

 printf("入力された数値は%dと%lfと%dです\n",InumA,Dnum,InumB); //結果

 return 0;
}

Cの型

Cには型がある。今日、勉強した。
int,double,charなどに変数を代入し、格納するために必要だそうだ。
たとえば、int型に整数を格納出来、それ以外の数を代入しようとするとコンパイルエラーとなる。

Hello.c world!!

これは、世界で有名なプログラミングで文字列をコンソールに表示するため、プログラミングです。
#include<stdio.h>
int main(void)
{
     printf("Hello.c world!!");
return 0;
}

Fed's Yellen more complex than dove label implies

I think her appointment was the best choice for US macro economy.
Fed's Yellen more complex than dove label implies
| Reuters
: "Yellen's name is inevitably mentioned among the Fed's most dovish members, or those more likely to favour lower interest rates to support economic growth and boost labour markets."

Treasury Auctions Set for This Week - Schedule

Treasury Auctions Set for This Week - Schedule - NYTimes.com: "The Treasury’s schedule of financing this week includes the regular weekly auction of new three- and six-month bills on Monday, and an auction of four-week bills on Tuesday."

Greek Bonds Advance After European Leaders Back Rescue Plan

Spreads between Greek bonds and German bunds tightened, as a relief reaction that a deal has been reached among EU nations.

Greek Bonds Advance After European Leaders Back Rescue Plan - BusinessWeek: "Greek bonds rose, with the two-year yield headed for its biggest weekly drop since March 5, after European Union leaders backed a framework to rescue the nation should it be unable to narrow the bloc’s biggest budget deficit."

アルゼンチン、債務スワップに関する有価証券届出書を関東財務局に提出

アルゼンチン、債務スワップに関する有価証券届出書を関東財務局に提出
| Reuters
: "アルゼンチン政府は25日、日本で債務不履行に陥ったソブリン債のスワップ計画の条件を関東財務局に提出"

FAPRI Says Economic Turnaround Will Fuel Crop Price Recovery

WTI oil future price is in a random walking at 80$ per a barrel at the moment.But if oil price is pressured upside momentum lead by strong demands from Asia,the price would be beyond 100$ with no wonder.So Who`s gonna survive?
Wallaces Farmer - FAPRI Says Economic Turnaround Will Fuel Crop Price Recovery: "The economic recovery will be accompanied by projected stronger energy prices. The FAPRI economists expect that the continuing recovery of crude oil prices along with bioenergy mandates will grow the demand and strengthen the world price of ethanol through 2019. Global net trade in ethanol is projected to increase by 3.12 billion gallons and reach 4.15 billion gallons by 2019."

India faces more rate hikes to tame inflation



Reserve bank of Indian is in a rush to tighten.

India faces more rate hikes to tame inflation: Analysts- Indicators-Economy-News-The Economic Times: "RBI looks set to tighten monetary policy further after raising interest rates for the first time in nearly two years as it bids to check Burst the Inflation balloon
Implications of a rising inflation rate
spiralling inflation, economists say.

In a move that surprised experts, the Reserve Bank of India (RBI) hiked short-term rates from record lows late Friday to battle near double-digit annual inflation amid fast-strengthening industrial output.

Expectations had been for a rate hike at the bank's scheduled policy review on April 20 but the RBI said in a statement that inflation had 'been a source of growing concern.'

The wholesale price index (WPI) in Asia's third-largest economy was 9.89 percent in February, well above the central bank's own estimate of 8.5 per cent by the end of the current financial year this month.

On Friday, the RBI raised the repo, the rate at which it lends to commercial banks, by 25 basis points to 5.0 per cent."

Teva to buy Ratiopharm for nearly $5 bln |

Israel drugmakers are having a strong competitiveness in that sector.



Teva`s chart

UPDATE 6-Teva to buy Ratiopharm for nearly $5 bln
| Reuters
: "Israel's Teva (TEVA.TA) (TEVA.O) won the battle for generic drugmaker Ratiopharm, paying 3.7 billion euros ($5.1 billion) to fix its weakness in Germany, the world's second-largest generics market."

Argentine economy expanded or contracted in 2009?



MERV(Argentina stock index) vs BSVP(Brazil) vs (Mexico)



Guessing time: Argentine economy expanded or contracted in 2009? — MercoPress: "Argentina's government expects the economy to grow 2.5% in 2010, according to its budget proposal. That compares to official forecasts of 6% growth in Brazil, Latin America's largest economy and 3.9% in Mexico, the region's second largest economy.
Argentina's growth and industrial output data releases were accompanied on Friday by additional financial information from the government.
The primary budget surplus narrowed to 1.21 billion pesos (310 million USD) in February from 1.60 billion pesos reported in February 2009. Tax income growth has slowed as Argentina's economy tries to pull out of the 2009 slowdown caused in part by the world financial crisis.
The government faces about 15 billion USD in debt payments this year as it seeks regulatory approval to reopen the country's 2005 debt restructuring. Argentina hopes to re-enter the international capital markets once it restructures 20 billion in paper left over from the country's 2001/2002 debt default."

Argentina industry output jumps on Brazil demand

Argentina economy looks expanding with Brazilian domestic consumptions.

WRAPUP 2-Argentina industry output jumps on Brazil demand
| Reuters
:
"* 11 pct industrial output rise blows past market view

* Car exports to Brazil help keep production healthy"

Finance Bonds Pull Ahead as JPMorgan Sells Debt: Credit Markets

Some people see those attractive.

Finance Bonds Pull Ahead as JPMorgan Sells Debt: Credit Markets - BusinessWeek: "Debt sold by banks, insurers and brokers returned 0.81 percent this month through yesterday, compared with 0.4 percent for the rest of the market, according to Bank of America Merrill Lynch index data. The cost to borrow for banks is the lowest since February 2008, with yields falling to within 1.93 percentage points of Treasuries on March 18."


2010年の半導体支出は2けた成長の見込み

2010年の半導体支出は2けた成長の見込み--米調査:ニュース - CNET Japan: "OEM(Original Equipment Manufacturer)による2010年の半導体支出は、前年比で13%と大幅に増加し、1779億ドルになると予測されている。一方、EMS(Electronic Manufacturing Service)プロバイダによる2010年の支出は、前年比15.1%増の377億ドルになる見込み。"

Bank of Canada sees low rates, but not copying Fed | Business | Reuters

Bank of Canada sees low rates, but not copying Fed
| Business
| Reuters
: "The Bank of Canada believes interest rates should stay at near-zero levels for another few months even though the economy is showing signs of quicker than expected recovery, the central bank chief said on Thursday.

At the same time, Bank of Canada Governor Mark Carney said there was no need for Canada to align its interest rate moves with those of the United States, as speculation grows that Ottawa could start removing emergency stimulus measures before Washington does."

Argentine trade surplus widens 25 pct in January

Argentine trade surplus widens 25 pct in January
| Reuters
: "Argentina's trade surplus widened 25 percent in January from the same month a year ago as both exports and imports rose, signaling an economic recovery is underway in Latin America's No. 3 economy."
The country's manufacturing exports have been boosted, however, by soaring car exports to neighboring Brazil, where government tax breaks have increased demand.


Sterling sinks as King talks of releasing more money

Sterling sinks as King talks of releasing more money - Times Online: "Mervyn King, the Governor of the Bank of England, warned again that it may be necessary to extend the Bank’s asset purchase programe"

Mr King told the Treasury Select Committee that the Bank was “ready to do whatever seems appropriate”.


Heineken and Carlsberg see contrasting fortunes

BBC News - Heineken and Carlsberg see contrasting fortunes: "Dutch brewing giant Heineken has forecast lower beer consumption in many regions this year as it reported a drop in sales volumes in 2009."

Instead,Carlsberg reported a 38% rise in profit to 3.6bn Danish Kroner ($660m; £425m) in 2009, driven by strong performances in Eastern Europe and Asia.
The group's beer volumes increased 6%, although currency fluctuations meant revenues fell 1%.

Commodities fall on economic concerns

Prices showed a concern that Two big economy showed shrinking sign.

Commodities fall on economic concerns - washingtonpost.com: "Prices for metals and energy futures fell Tuesday after worries about the global economy had investors seeking the safety of the dollar."
German business confidence dropped for the first time in 10 months in February raised concerns about Europe's largest economyc

US commercial real-estate sales rose sharply

I will see while this movement shows that the market hit bottom.
"The number of commercial real-estate sales rose sharply in December, triggering fresh debate about whether the sector has reached bottom. Property sales, a gauge of market health, rose 75% in December from the prior month, according to Real Capital Analytics. The end of the year traditionally sees an increase in volume. But the recent increase is significant even after adjusting for that"
- Commercial-Property Sales Jump - WSJ.com 

US stock down




This is a kind of price adjustment circle.

"Feb 23 (Reuters) - U.S. stocks suffered their biggest one-day decline in nearly three weeks on Tuesday after a sharp drop in consumer confidence heightened worries over one of the most vulnerable areas of the economy."
- US STOCKS-Wall Street drops along with consumer confidence | Reuters 

1月貿易収支

外部環境の好転が続き、輸出は前年比40.9%伸びるなどし、増加傾向が継続。

"輸出は前年比40.9%増加"
- 1月貿易収支は852億円の黒字、12カ月連続の黒字 | Reuters 

consumer comfort index shrink

Data showed almost lowest number.

"Consumer Comfort Index hit the dreaded -50 mark for the first time in nearly four months this week, a mere four points from its record low in 24 years of weekly polls"
- ABC News Poll: Consumer Confidence Hits the Dreaded -50 Mark - ABC News (view on Google Sidewiki)
 

Soros warns about future of the Euro and Euro-zone

I agree his view.


It seems to me that EU official were done nothing yet.


If investor turn eyes on German risk,she has a lot of Greece debts.

"”A makeshift assistance should be enough for Greece, but that leaves Spain, Italy, Portugal and Ireland. Together they constitute too large of a portion of Euro-land to be helped in this way,” Soros said"
- Financier Soros warns about future of the Euro and Euro-zone — MercoPress 

IFO report

German sentiment is still struggling.

"business sentiment index slipped to 95.2 from 95.8 in January"
- Germany's Ifo business climate gauge falls in Feb. Economic Report - MarketWatch 

Bolivia, Argentina near natgas exports agreement

agreement including build cross-border natural-gas pipeline.


UPDATE 1-Bolivia, Argentina near natgas exports agreement | Reuters

景況判断


外需などの外部要因が不透明。
在庫拡大に一服感。
in reference to:
"景気は「持ち直してきている」との基調判断"
- NIKKEI NET(日経ネット):写真ニュース-最新のニュース写真を掲載 

Asian Stocks Drop on Valuation Concerns

The average price of the gauge’s companies to 1.55 times book value, the highest level since Feb. 3.

"the average price of the gauge’s companies to 1.55 times book value, the highest level since Feb. 3."
- Asian Stocks Drop on Valuation Concerns; Copper, Oil Decline - Bloomberg.com

Nikkei225

28000-28550 up in the early session, down lately.