C
ãWEB+DB PRESS vol.35ã*1ã®ã³ã¼ããªã¼ãã£ã³ã°ç¹éã®ã第4ç« Cè¨èªã³ã¼ããªã¼ãã£ã³ã°ããèªã¿ã¾ããã éè¦ãªæ§é ä½ãè¦ã¤ããã¹ã ãã¯ãã追ãã¥ãããã°ããªããã»ããµã§å±éãã¦ãã¾ã ãã°åºåãã¦ãã¨ã©ã¼ãã°ã追ã gdbã使ã çã ãCè¨èªã®ã³ã¼ãâ¦
imakeã³ã¼ããªã¼ãã£ã³ã°ã¡ã¢ãããªããã»ããµé¨ãç·¨ã§ãã# ããã¾ã§ã®éã®ããä¸ã»ã©æ°ã xmkmfã¨imakeã«ããMakefileçæ - èå¡ ã¡ã¢: lndirã³ãã³ã - èå¡ çåã¡ã¢: ãã«ãããGCCã®ãã¼ã¸ã§ã³ - èå¡ ãBuilding and Installing the X Window Systemâ¦
飽ããã®ã§çãè¦ã¾ãããï¼¼(^o^)ï¼è§£çä¾ãæ¬ã«è¦ã¤ãããªãã¨åã«æ¸ãã¾ããããèè ã®Webãµã¤ããããµã³ãã«ã³ã¼ãããã¦ã³ãã¼ãã§ããå½¢å¼ã§ããã åé¡ ã¿ãæåï¼'\t'ï¼ãã\tããæ¹è¡ãã'$'ï¼æ¹è¡ãã¨ãã¦åºåããcatã³ãã³ããæ¸ããªããã 解çä¾â¦
ããµã¤ãã®Linuxããã°ã©ãã³ã°ãã«å ¥éãã¦ãç·´ç¿åé¡ã解ãã¦ãã¾ããååï¼http://d.hatena.ne.jp/torazuka/20110706/cï¼è§£ããªãã£ãåé¡ã®ç¶ãã åé¡ ã¿ãæåï¼'\t'ï¼ãã\tããæ¹è¡ãã'$'ï¼æ¹è¡ãã¨ãã¦åºåããcatã³ãã³ããæ¸ããªããã ååãã¿â¦
# ããããï¼é¢¨ã«ããµã¤ãã®Linuxããã°ã©ãã³ã°ãã«å ¥éä¸ã§ããããã®ã¾ã¾ä»èµ·ãã£ããã¨ã話ãã¨ãããã¡ã¤ã«å ¥åºåã®åå¼·ããã¦ããã¨æã£ãããCè¨èªã®åå¼·ã«ãªã£ã¦ããããä½ããã£ã¦ããã®ããåãããããªãããã©ãããããªã«ã³ã¸ã«ã åé¡ ã¿ãæâ¦
ãã¼ã«ã®å®è£ ãèªãã§ããã¨ãLinuxã®ã·ã¹ãã ã³ã¼ã«ãã·ã°ãã«ã®ç¥èã足ããªãã¦ãã¨ãã©ãç解ã§ãã¾ãããä¾ï¼ãã·ã°ãã«ãåºãã¨ãã¯killé¢æ°ã使ããããããã©ããã¼ã«ã®ä¸ã§ã¯signalé¢æ°ä½¿ã£ã¦ããâ¦ã©ããããã¨ãªã®â¦ âãã¾ããã¨ããããã§ãããµã¤â¦
The C Preprocessor ãªãã§ä»ã¾ã§èªãã§ãªãã®ãã¨ãããªããã»ããµã«ã¤ãã¦æ©ãã ãã¨ã®ãã話ããä½ããä½ã¾ã§æ¸ãã¦ããã¾ãããï¼å½ããåï¼ #include ã¯ã·ã¹ãã ãã¡ã¤ã«ã#include "filename" ã¯ã¦ã¼ã¶ãã¡ã¤ã« ããããã¡ã¤ã«ã®éè¤èªã¿è¾¼ã¿ãé²ããâ¦
cppï¼Cããªããã»ããµï¼ã³ãã³ãã«ã¤ãã¦å¦ãã ã®ã§ã¡ã¢ãCã³ã³ãã¤ã©ãå é¨ã§èµ·åããããªããã»ããµã§ãããåä½ã§å®è¡ãããã¨ãã§ãã¾ããã»ã»ã»ã§ãããã¶ãããã¾ãããªãã®ããï¼ $ which cpp /usr/bin/cpp Invoking the C Preprocessor è²ã ãªãã·ã§â¦
ã²ã¨æåã®ä½æ¥ãåéã xmkmfã¨imakeã«ããMakefileçæ - èå¡ Xããã«ããããã¨ãã¦ãã¾ããã½ã¼ã¹ã³ã¼ãã«ã¤ãã¦ãããBuilding and Installing the X Window Systemãã¨ããããã¥ã¢ã«ãèªãã¨ã"1å°ä»¥ä¸ã®ãã·ã³ã§ãã«ãããã¨ãã¯ãlndirãå®è¡ãã¦â¦
Javaã®ãªãã¸ã§ã¯ãåç §ã¯ãCã®ãã¤ã³ã¿ãã©ãããããããªã¢ãã§ãããã¨ããç解ãªã®ã ããã©ãè¦ã¯ä½ãªã®ã ãã? - Java C C++ ä»®å¼æ°ãåºæ¬ãã¼ã¿åï¼Javaï¼ or å¤æ°ã®ã¿ï¼C/C++ï¼ å¤æ¸¡ã å¤æ¸¡ã å¤æ¸¡ã ä»®å¼æ°ãé åããªãã¸ã§ã¯ãï¼Javaï¼ or å¤æ°*ï¼Câ¦
ä½ãã¤ããã«å®ç¾©ããå¤æ°ã¯ãåæå¤ãä¸ããªãã¨ãä¸å®å¤ã§åæåããããautoãregisterãã¤ãã¦å®ç¾©ããå¤æ°ãåãã staticãã¤ãã¦å®ç¾©ããå¤æ°ã¯ãåæå¤ãä¸ããªãã¨ã0ã§åæåããããmainé¢æ°ã®å®è¡åã«çæãããããã°ã©ã çµäºæã«æ¶æ» ããã ä»®â¦
沢山ã®äººããã¨ã¯ãªãã¹ãããããã§ã³ãè²°ã£ã¦è¡ã£ã¦ãããããã ããã©ã»ã»ã»èªãã§ãã»ããæ¥ãããããªããããä½ã¬ãã«ãªCã®å¦ç¿è¨é²ã¯ããããªæ¥ããæ·¡ã ã¨æ´æ°ããããï¼ãã¾ãï¼ è¦ããã㨠å¤æ¬¡å é åã®ä»®å¼æ° é¢æ°ã®ä»®å¼æ°ã«å¤æ¬¡å é åãæ¸ãã¨ãâ¦
ï¼è¿½è¨: Enterãã¼æ¼ãããæ稿ããã¦ããããã¡ãã£ã¨ä¿®æ£ãã¯ã¦ãªã§ã»ã»ã»ï¼ ä½ãã£ã¦ãã®? 観念ãã¦ææ´æ¬ã®å ¥éç·¨ãå ¥æããã®ã§ãèªãã ãæ¸ããããã¦ãã¾ãããããããåºæ¬çãªææ³äºé ã®èª¬æãã¡ããã¨è¼ã£ã¦ããã»ã»ã» æ¥ããããããã«æåããå ¥â¦
ä»æ¥è¦ããã㨠0/é0 Cè¨èªã§æ¨æºé¢æ°ãå¦ã¶ã¨ãã¯ãæ»ãå¤ã«æ³¨æãããã¨ãã©ãããã¨ã0ã§ãã©ãããã¨ãé0ãªã®ããifæã®å¶å¾¡å¼ã§é¢æ°ãè¦ããã¦ãæ»ãå¤ã©ããªããã ã£ãï¼ã¨æ··ä¹±ãããã調ã¹ããã¨ãèªåã®ç´è¦³ã¨åããå ´åãããã ä» %æ¼ç®åã¯ãæ£â¦
ãCode Readingã第2ç« ãèªãã ãåãã¦åãããããã¤ã¤ãè¦ãããã¨ã¨ãã¯ã«ã©ã³ãã¨ã¨ãã¡ã¢ãç°å¢ï¼Visual C++ 2010 Express __Pãã¯ãã®æå³ Pãã¯ãã¯ãANSI以åã®ã³ã³ãã¤ã©åãã®é¢æ°å®£è¨ã åèï¼http://ogawa.s18.xrea.com/tdiary/20031211.html#pâ¦
ä»æ¥è¦ããã㨠æå種å¤å¥ã®é¢æ°ãããã å¶å¾¡æå: iscntrl 空ç½æåãå«ã表示æå: isprint 空ç½æåãå«ã¾ãªã表示æå: isgraph 10é²æ°å: isdigit 16é²æ°å: isxdigit è±å¤§æå; isupper è±å°æå: islower è±æ°å: isalnum è±æ°åã§ã空ç½ã§ããªã表â¦
ä»æ¥è¦ããã㨠ãã¡ã¤ã«ã¹ã³ã¼ã é¢æ°ã®å¤ã§å®£è¨ããå¤æ°ã¯ããã¡ã¤ã«å ã®ãã¹ã¦ã®é¢æ°ããåç §ã§ãã Cè¨èªãããæ¦å¿µããã¡ã¤ã«ã¹ã³ã¼ãã«ç¸å½ãããã®ã¯ãJavaã«ã¯ãªãï¼ããºï¼ å é¨æå¹ç¯å²ã®å¤æ°ããå¤é¨æå¹ç¯å²ã®å¤æ°ãé ã ãã¡ã¤ã«ã¹ã³ã¼ãã§å¤æ°hâ¦
ä»æ¥è¦ããã㨠setlocaleé¢æ° æåååºæã®ç°å¢ã«è¨å®ããã setlocale(LC_ALL, ""); 第2å¼æ°ã§ç©ºæåã渡ããã¨ã¯ã次ãæå³ããã localeã®å¤ã""ã®å ´åãå¦çç³»å®ç¾©ã®åºæã®ç°å¢ãæå®ããã BohYoh.comãï¼£è¨èªè¬åº§ãæ¨æºã©ã¤ãã©ãª setlocale ããããªâ¦
ä»æ¥è¦ããã㨠charå charåã¯ãæåã表ãæ´æ°åã§ã3種é¡ãã signed char unsigned char char ç¡å°ã®charåã¯ãsigned charãunsigned charã®ã©ã¡ããã¨çããåãã©ã¡ãã«çãããã¯ãå¦çç³»ã«ä¾åãããã»ã»ã»ã¨ãããã¨ã¯ãå¦çç³»ã«ä¾åããæ¸ãæ¹ãâ¦
æªè§£æ±ºã§ããç°å¢ãæ´ã£ãæã®ããã«ãã°ã°ã£ã¦åºã¦ãã解決çãè²¼ã£ã¦ããã¾ããã¨ã»ã» ç¾è±¡ VC6ã®ããã¸ã§ã¯ããã¡ã¤ã«ãVC++2010ã®ããã¸ã§ã¯ãå½¢å¼ã«å¤æã§ããªããdspãã¡ã¤ã«ãé¸æãã¦éããã¨ããã¨ãç¾å¨ã®å½¢å¼ã«å¤æãããèããããï¼»ã¯ãï¼½ãé¸â¦
ä»æ¥è¦ããã㨠å¯å¤é·å¼æ°ã®æ¸ãæ¹ ã...ãã§ãä»»æåãä»»æåæ° çµç«¯ãnullã«ãªãæååé åã¨ãnullæåãå«ã¾ãªãæåã®é åããã é åã®å®£è¨æã«ãè¦ç´ æ°ã´ã£ããã®æåã§åæåããã¨ãå¾è ã®é åãçæããã ä»æ¥æã£ãã㨠printfã¨scanfã®ä»æ§ãâ¦
ä»æ¥è¦ããã㨠clocké¢æ° èµ·åããã®ã¯ããã¯æ°ãæ±ããã æ»ãå¤ããç§ãæ±ããã«ã¯ãCLOCKS_PER_SECã§å²ã æ»ãå¤ã®clock_tã¯ãä½ããã®ç®è¡åã®å義èªã¨ãã¦å®ç¾©ããã æå ã®ç°å¢ã§ã¯ãtypedef long clock_t ã¨ã©ã¼ã®ã¨ãã¯ã-1ãclock_tåã«ãã£ã¹ããâ¦
ä»æ¥è¦ããã㨠æ¡å¼µè¡¨è¨ \fï¼æ¸å¼éã ããªã³ã¿åºåã§æ¹ãã¼ã¸ãããã¨ãã«ä½¿ã \vï¼åç´ã¿ã ãããããªã³ã¿åºåã§ä½¿ã æ°´å¹³ã¿ãã¨éã£ã¦ãç»é¢ã«åºåãã¦ãæååãããã ãï¼ãã ãç°å¢ã«ããããºï¼ putcharé¢æ° å¼æ°ã«ä¸ããããæåã表示ãã å¼æ°ã¯iâ¦
ä»æ¥è¦ããã㨠ãã¼ã«ã«å¤æ°ã¯ãããã¯ã®å é ã§å®£è¨ãã ã·ã©ãã«ãã¿ãå¤æ°ã¯ä½¿ãç´åã«å®£è¨ããæ¹ãåãããããã¨ãã¨æã£ã¦ãä½ã®æ°ãªãã«æ¸ãããåããªãã£ããforæã®()ã®ä¸ã§ãå¤æ°ã宣è¨ã§ããªããã¨ã¯ãç¥ã£ã¦ãããã©ãããã putsé¢æ° NULLæåâ¦
ä»æ¥è¦ããã㨠randé¢æ°ã使ç¨ãã¦æ¬ä¼¼ä¹±æ°åãä½ã ããããrandé¢æ°ããã®ã¾ã¾ä½¿ãã¨ã種ã«å®æ°1ã使ç¨ããã¦ãã¾ã ãã®ãããrandé¢æ°ããåã§ãsrandé¢æ°ãå¼ã³åºã srandé¢æ°ã¯ãæ¬ä¼¼ä¹±æ°ç³»åçæã®ç¨®ã«å¤ãè¨å®ãããã¨ã§ãä¹±æ°ã®çºçç³»åãå¤æ´ããâ¦
scanfã¯äºæããªãå ¥åãããã¨ç¡éã«ã¼ãã«é¥ãï¼Cå¦ç¿ä¸ï¼ã®ã¤ã¥ãã ä»æ¥ã»ãã£ãã㨠scanfã®æ»ãå¤ã使ã£ã¦å ¥åã®æ£èª¤å¤å®ããã空èªã¿ã§ç¡éã«ã¼ããåé¿ãã int hoge; int ans = 7; while(1){ // ç°å¸¸å¤å¯¾ç if(scanf("%d", &hoge) != 1){ printf("â¦
ä»æ¥è¦ããã㨠scanf 㧠int åã®å¤æ°ã«å¤ãåãåããããå¤ã¨çãããã° break ãããããã¾ã§ while(1) ã§åããã¨ããã³ã¼ããæ¸ãã¦ãããããããã®ã int hoge; int moga = 7; while(1) { scanf("%d", &hoge) if (hoge < moga) { // hogeãå°ããã¨â¦
ä»æ¥è¦ããã㨠å¼æ°ã®ãªãé¢æ°ã宣è¨ããã¨ãã¯ãæ¬å¼§ã®ä¸ã«voidã¨æ¸ãå¿ è¦ãããã åè: ÂÃÂÂÂÃÂvÂÂÂgÂ^ÂCÂv ããã¯ã ãã§ã int main() ããããããããJavaã¨éãã int main(void) scanfã§ãå¤ãåãåãå¤æ°ã«&ãä»ãå¿ããã¨ãå¤ãåãåããªãããâ¦
ä»æ¥è¦ããã㨠intã¨charã®ãµã¤ãºãçããç°å¢ã§ã¯ãæåã¨EOFãæ¯è¼ãã¦ã¯ãããªãã ãï¼intããããã¯ï¼EOFãè¿ãé¢æ°ãã®æ»ãå¤ã¨ã¯æ¯è¼ãã¦ãããããã FILE *fp; while(c != EOF){ c = getc(fp); // è²ã } ã¯æ¨å¥¨ãããªãã¨ãããã¨ã§ããã ãããâ¦
ä»äºã§ã¿ã¦ããOSSã®ãã¼ã«ãCãªã®ã§ããããã¾ã§æ°åãã§èªãã§ããã®ã§ãããç解ãããã®ã§ãæ¥ãæ¨ã¦ã¦å ¥éãããã¨ã«ã æè¿è¦ããã㨠ã³ãã³ãã©ã¤ã³å¼æ°ã®1ã¤ç®ã¯ãé åã®2ã¤ç®ã®è¦ç´ ã«å ¥ã£ã¦ãã ãã¡ã¤ã«ãã¤ã³ã¿ã宣è¨ãããåå¾ãããã¨ããæ¦å¿µâ¦