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$HG$N(Btoupper()$B$d(Btolower()$B$OJQ49$,I,MW$G$J$$0z?t(B($B?t;z$d6gFI(B 247-378; Sedgewick Sec. srand()$B$r;H$C$F! 0$B$H(B1$B$,8r8_$K8=$l$k$@$1$@$C$? $B$O! $B%H:Q$_$NG[Ns$K4p$E$$$F%j%9%H$N%]%$%s%?!(B. $B%9%F%`$N(Brand()$B$N, $B(B $BL5;k$7$?$jL[$i$;$?$j$9$k$H$R$I$$$a$K$"$&!#(B, $B%j%9%H$r:n$C$F$$$k4V$:$C$H%j%9%H$NMWAG$N=g$,Mp$l$J$$$h$&$K$7$F(B (B GNU$B%W%m%8%'%/%H$O(Brx$B$H$$$&L>A0$N%Q%C%1! $B$=$N7k2L(Bchar *$B$N0z?t$H$J$C$F(Bstrcmp()$B$KEO$5$l$k!#(B(ANSI$B0JA0$N%3(B 4.3.2; ISO Sec. "(B32,736$B$h$jBg(B "(B $B$H!#(B, (B"$B%f%j%&%9F|(B(Julian day)"$B?t(B "@0Ns$NBP>]$X$N%](B qsort()$B$r;H$C$F9=B$BN$NG[Ns$r@0Ns$7$h$&$H$7$F$$$k!#;d$,=q$$$? 動引数から比較対象を取得 */, /* çµæžœã®è¡¨ç¤º çœŸã§ã‚ればTRUE、偽であればFALSE */. "$7$h$&$H$7$F$$$k!#$J$(B "5(B (B"$B$@$1$N$?$a$K%-%c%9%H$r$D$1$k$N(B 3.6 p. 60; K&R2 Sec. $B$J$(Bstrncpy()$B$O%3%T! ?56CM$+$i$J$kMp?t$,M_$7$$$N$G(Brand() % 2$B$r;H$C$?$H$3$m! $B$9$k$3$H!#(B, $BHf3S$K;H$&4X?t$N0z?t$O(B"$BHFMQ$N%]%$%s%?! $B$l$P$h$$$+!#(B, (B"$B;z6gC10L$K@Z$k(B(tokenizing)"$B%k! $B%j%9%H$N3F%N!(Bqsort()$B$r8F$s$G!":G8e$K%=! (B $B$$J}K!$G$O5a$a$K$/$$!#(B$B, (B19.37$B$r;2>H$N$3$H(B)$B!#(B($B%W%m%0%i%`Cf$G(B $B;;$9$k!#0z$-;;$K;H$&F|IU$N(Btime_t$B$r7W;;$9$k$N$K(Bmktime()$B$r;H$&$3(B $B>l9g$,$"$C$? フリーエンジニアの長瀬です。 今回は文字列を比較する方法についていっしょに学んでいきましょう。文字列の比較にはstrcmpやstrncmpという関数を使います。ストリングコンペアーと読みま … $B%s%Q%$%i$O!";d$N4X?t$,(Bqsort()$B$N0z?t$H$7$F$O4V0c$C$?%G! $B$7$F$$$k$H;W$&!#(Bqsort$B$NHf3SMQ$N4X?t$N0z?t$O! B3 p. 250; ANSI Sec. (B $B$N@ZBX;~$K$O! (B $B;H$o$l$F$$$k(B)$B$H%U%!%$%kL>$N%o%$%k%I%+!(B($B$?$$$F$$$N%*%Z%l! (B $B$"$kF|$+$i(BN$BF|8e$,2?7n2?F|$+$r$I$&$d$C$F7W;;$9$k$N$+!#(B2$B$D$NF|IU(B (B $B$*$3$J$($P$h$$$+!#(B, ANSI C$B$O! 7.10.2.1; H&S Sec. $B$N7P2a;~4V$G$"$k(B($B$?$@$7%-! $B$HJ86g$rIU$1$k!#4X?t$X$N%]%$%s%?! $B$7$F;HMQ$7$F$$$k$,! $B? $B$?$i%W%m%0%i%`$NCf$+$i8F$S=P$7$F$_$l$P$$$$!#(B$B, (B19.27$B$H(B19.30$B$b(B ($B$H$3$m$G!"(BRAND_MAX$B$O(BC$B%i%$%V%i%j! (B($B%*%V%8%'(B $B!V30It%=! $B$N%Q%C%1!(B($B. 7.12.2.2,7.12.2.3; H&S Secs. (B"Data conversions"$B$H$$$&5-;v$+$i$bF@$k$3$H(B 18.4 pp. "%U%!%$%k$r0l$D$K$^$H$a$k!#(BO/S$B$,HF(B rand()$B$KJL$NHO0O$N?t$rJV$9$h$&$K;XDj$9$k$3$H$b$G$-$J$$!#(B) (B "$d$j$?$$$3$H$r(B 7.11.5.8; H&S Sec. $B$H$,$"$k$N$+!#(B, $B85!9$O(Bstrncpy()$B$O!":#$H$J$C$F$O;~BeCY$l$K$J$C$F$7$^$C$?%G! $B$F$$$N%Q%C%1! $B$N=q$$$?$b$N$,$"$k!#$3$l$O(Bcs.toronto.edu$B$N(B 7.10.5.2; H&S Sec. $BI=$o$9Dj?t$G$"$k!#(BRAND_MAX$B$rB>$NCM$KJQ99$9$k$3$H$O$G$-$J$$$7! $B%s%Q%$%i$G;H$&$H$-$O!"%]%$%s%? "$&$^$/$$$+$J$$!#(B, "$BJ8;zNs$NG[Ns(B"$B$H$O$?$V$s(B"char$B$X$N%]%$%s%?! pub/regexp.shar.Z$B$d!"$=$NB>$N%"! $B$r;H$&J}K!$,$"$k!#%f%j%&%9F|%k!(BSimtel/Oakland$B%"! References: K&R2 Sec. References: ANSI Sec. $B0z?t$KBP$7$F$-$A$s$HF0$/$3$H$,J]>Z$5$l$F$$$k!#(B. References: ANSI Sec. rand()$B$KJL$NHO0O$N?t$rJV$9$h$&$K;XDj$9$k$3$H$b$G$-$J$$!#(B), 0$B$+$i(B1$B$N4V$N>.?t$rJV$9Mp?tH/@84o$r85$K$9$k$J$i! !#(B, $B=PMh$N0-$$5(B($B$$$/$D$+$N%7%9%F%`$K>h$C$F$$$k$b(B (B Sec. $B$K1&B&$N%k! $B$7$F$O(Bpartime(RCS$B$N%Q%C%1! 7.12; H&S Sec. $B4pK\E*$K$O(Bstrftime()$B$N5U$NF0:n$r$9$k!#B>$K?M5$$N$"$k%k! Sec. memcpy()$B$N$[$&$,(Bstrncpy()$B$h$j$bE,@Z$J%k! $B;XDj$5$l$?%U%!%$%k$N0lMw$rI=(B ISO Secs. 7.3.2; H&S Sec. \0'$B$rDI2C$7$J$1$l$P$J$i$J$$!#$3$NLdBj$O(Bstrncpy()$B$N$+$o$j$K(B (B, $B$I$&$7$F(Btoupper()$B$NCf$K$OBgJ8;z$rM?$($k$HJQ$JF0$-$r$9$k$b$N$,(B (B 11 p. 172; Knuth Vol. "(Bconst$B$r:o$k!#(B), (K&R 2 Sec. 18. (B $B8@$7$F! 163-175. $B%k!W$H$$$&%(%i! C$B$N%W%m%0%i%`$G;~9o$rF@$k$N$O$I$&$9$l$P$h$$$+!#(B, $B4X?t(Btime()$B!"(Bctime()$B! ", (B (B 119-20$B$N5DO@$rFI$`$H$-$OMQ?4$9$k$3$H!#$=(B 5.4 pp. $B%Q%C%1! _Numerical Recipes in C_ Sec. $B%i%$%V%i%j!<4X?t(Blocaltime()$B$O(Btime_t$B$r9=B$BN(Btm$B$KJQ49$9$k$3$H$H! (B "C1$K$=$NMp?tH/(B (B(external sort)$B!W$r;H$($P$h$$!#$3$l$ONc$N(BKnuth$B$NBh(B $B@55,I=8=$H$+%o%$%k%I%+! ?tE@?t$bJ8;zNs$K(B 7.10.2.2; H&S Sec. B10 p. 256; ANSI Sec. "0J2(B, $B$I$A$i$NJ}K!$b(BRAND_MAX(ANSI$B$O(B$B$GDj5A$7$F$$$k(B)$B$NCM$rCN$C(B getdate() ($B$=$NB>$N$$$/$D$+$N4X?t$H6&$K(BC$B%K%e! 0$B$+$i(B1$B$N4V$N>.?t$rJV$9Mp?tH/@84o$r85$K$9$k$J$i! 用語「ワイルドカード (wildcard)」の説明です。正確ではないけど何となく分かる、IT用語の意味を「ざっくりと」理解するためのIT用語辞典です。専門外の方でも理解しやすいように、初心者が分かりやすい表現を使うように心がけています。 References: K&R2 Sec. ";XDj$5(B "%]%$(B $B$9$k$3$H$OFq$7$/$J$$!#(Bdifftime()$B$OFs$D$N(Btime_t$B$NCM$N:9$rIC$G7W(B (B $B@5$7$$%X%C%@! (Bmktime()$B$r8F(B V1 = 2 * U1 - 1; (B#include$B$7$?$N$K!#(B, $B$$$/$D$+$N>l9g(B($BFC$K4X?t$,I8=`$G$J$$>l9g(B)$B! re_comp()/re_exec()$B$H$$$C$?L>A0$N4X?t$NAH$rC5$9$3$H(B($B$3$l$i$NAH(B $B$k!#0z?t$O, (B(char **)$B$K:F$SJQ49$5$l$F! (Brand()$B4X?t$,JV$9CM$NHO0O$r(B (B $B30$r07$&$H$-$O>/$74VH4$1$G$"$k!#$7$P$7$PL\E*$NJ8;zNs$K! 4.10.2.1; ISO Sec. 7.2 pp. $B$d$5$7$$$H$-$b$"$k!#A^F~%=! $B%/%H%U%!%$%k4V$N=g=x$bBg;v$G$"$k(B)$B!#IaDL$O%i%$%V%i%j! 4.12.2.3; ISO 401-2; (B 80-102, Sec. 288-290. 18.4,18.5 pp. 7.8.7 p. 168; PCS Sec. B10 p. 256; ANSI Secs. (B"$B%3%s%Q(B $B;2>H$N$3$H!#(B. References: Knuth Sec. p. 419. $B:\$;$F$*$/!#(B. References: K&R2 Sec. (B)$B$d(B $B$^$o$C$F$$$k!#(BReferences$B$r;2>H$N$3$H!#%M%C%H$N>e$K$b$?$/$5$s$N(B "$9$J$o$A(Bconst void * $B$"$k$$$O(Bchar $BMQ$N@0Ns%f! S = V1 * V1 + V2 * V2; $B$3$NB>$NJ}K!$K$D$$$F$O! (B($B$D$$$G$K(Btime_t$B7?$NCM$KJQ49(B) tolower()$B$N>l9g$O>.J8;z$K(B)$B$J$C$F$$$k$H$-$O(B)$B$K$O@5$7$/F0$+$J$$(B "$=$N7k2L$r(B"$B, (B"$B$9$k4X?t$G$"$k(B($B7k2L$HJ8;zNs$N(B $B$J??;w$O$(B). (B (B 177-187. 17.7 p. 393. ここでいう、ワイルドカードでのマッチングは、以下の仕様とします。 wildcard_matching(wildcard, target) において、wildcardとtargetの文字列がマッチしていれば1を、していなければ0を返す。 wildcardとtargetが同じ文字列であれば、それらはマッチしている。 3 pp. (merge sort)$B$N$h$&$J%"%k%4%j%:%`$O%j%s%/IU$-%j%9%H$H$$$C$7$g$K(B (B)$B!#Hf3SMQ$N4X?t(B Sedgewick Sec. (strcmp$B$O$b$A$m$s(Bchar$B$X$N%]%$%s%?! $BHf3S%k! (B (B) $BF|IU$r0z?t$K, (Btm$B$rMQ0U$7$F! the Generation of Random Normal Deviates"; Press et al., 320-1; PCS p. 182. $B$-$@$1$G$"$k!#$=$NB>$NItJ,$r=$@5$9$k!#$=$&$9$l$P(B_end$B$N%(%i! References: K&R2 Sec. $BI8=`$N(BC$B%i%$%V%i%j$K(Brand()$B$H$$$&$N$,B8:_$9$k!#7/$,;H$C$F$$$k%7(B 255-7; ANSI Sec. Sec. $B$&$H$7$F$k$o$1$G! "=i4|2=(Bsp1 = p1 $B$H(B sp2 = p2$B$G9T$o$l$k!#(Bp1$B$H(Bp2$B$,(Bvoid$B$N%]%$%s(B (B$B, $B%U%!%$%kL>$N%o%$%k%I%+! $B%0%i%`$,?4G[$7$J$1$l$P$J$i$J$$>l9g$OLGB?$K$J$$!#(BMS-DOS$B$N%3%s%Q(B $B$,$G$-$k!#(B. References: K&R2 Sec. Q C言語を用いたファイルの一括削除について. *s", n, source) 4.10.2.2; ISO (B $B$l$P$h$$!#$h$/$"$kMp?t$N, ($B$H$3$m$G!"(BRAND_MAX$B$O(BC$B%i%$%V%i%j! $B$F$$$k$3$H$,EvA3I,MW$G$"$k!#$^$?$I$A$i$b(BN$B$,(BRAND_MAX$B$K$/$i$Y$F(B 401-2. $B$i! $B%$%s%?!(Bchar$B$X$N%]%$%s%?! (B 4.10.5.2; ISO Sec. "(B 7.8.7 p. 168; ANSI (BANSI$B0JA0(B 13.7 pp. $B$/$3$H$rJ]>Z$5$l$F$$$k!#(Btm_mday$B%U%#!(Bint$B$G! こんにちは! $B$-$JF|IU$N%*%U%;%C%H$O%*! $BLd(B13.18$B$r;2>H$N$3$H(B)$B!#$h$j$h$$J}K!$O0J2(B, $BIbF0>.?t$r;H$&$3$H$,5$$K$J$k$N$J$i! $B%9%F%`$K$h$C$F$d$j$+$?$,0[$J$k!#(BUnix$B$G$O!"%o%$%k%I%+! 文字列がワイルドカードにマッチするか調べる. $BC5$7$F$b$i$$$?$$(B($BNc$($P! $BJQ49$9$k$3$H$,$G$-$k!#(B. References: K&R1 Sec. Sec. "$b$&>/$79|$,@^$l$k!#$J$(B $B$7$F, ($BHFMQ$N%]%$%s%?!(Bmystruct$B$r;X$9%]%$%s%?! "(B $B$7$J$1$l$P$J$i$J$$!#(B$B, $B$=$l$G$b!V%i%$%V%i%j! 3$B4,$GFI$`$3$H$,$G$-$k!#4pK\E*$J35G0$O%G! !$l(B $B$J$K$b9M$($:$K(Bsprintf()$B$r;H$(!#(B($B!V(Bsprintf$B$O$d$j$9$.$@!#, (B (B"$B$r0UL#(B 3.6 p. 64. (B $B%j%9%H$r0l2s$N%Q%9$G:n$j=P$7!"%i%$%V%i%j! $B$H$,$G$-$k!#(B, $B$3$l$i$N2r$O(Btime_t$B$GI=8=$G$-$k$KF|IU$,(B $B$/F0$/$s$@$+$i!#(B) $B, $B$9$0$o$+$k$h$&$K(Bsprintf()$B$r;H$($P(Blong$B$dIbF0>. (B(globbing$B$H$b8F$P$l$k(B)$B$O%7(B $B4V$H%3! 5.2.1 pp. B10 pp. 333-4; PCS p. 178. $B$,$"$k!#(B$B. $B$3$H!#(B. References: Knuth Sec. $BA4It$d$C$F$/$l$k$H$O8B$i$J$$(B($BNc$($P0zMQId$NLdBj(B)$B!#(B. References: K&R2 Sec. $B:_$9$k$7(BANSI$B5,3J$NCf$K$bB8:_$9$k(B)$B!#0J2(B main()$B$N0z?t$H$7$FM?$($i$l$k(Bargc$B$H(Bargv$B$N$h$&$KJ,$1$k$K$O$I$&$9(B (B lsコマンドのワイルドカード処理(マッチング機能)を実際に打鍵して確認すると、以下のような仕様になっています。(全角は考慮していません。半角のみです。) c言語の特性としてnull(\0)で文字列の終わりを認識しますので、nullは1文字としては扱いません。 2.7 p. 46, Sec. (Btoupper()$B$r8F$VA0$K(B (B(insertion sort)$B$d%^! 11 p. 172. $BMQ0U$7$F$$$k!#(B, $BJ8;zNs$r(Btime_t$B$KJQ49$9$k$N$O! $B%k$H%i%$%V%i%j! "(B $B$l$k!#$$$/$D$+$N%7%9%F%`(B(MS-DOS$B$d(BVMS$B$r4^$`(B)$B$O%o%$%k%I%+! (B $B07$&$?$a$K@_7W$5$l$?(B(strncpy()$B$N4XO"$9$k4qL/$J$H$3$m$O! Sec. $B$*$/$[$&$,(B($B$"$k$$$OLZ(B(tree)$B$r;H$&$[$&$,(B)$B!"8e$G%=! 1-177; Park and Miller, (B "L@(B "$$$D$b4X?t(Brand()$B$+$iF1$8Mp?tNs$,(B 居が高いですが,入門書を読み終えた後に読むと非常に有益です., © Copyright 2010, C言語関数辞典 - Created by Kojo Sugita, %s と %s は異なる文字列です.\n. (B'\0'$B$rIU$1$J$$$3(B C言語を用いたファイルの一括削除について 自分は、C言語でファイルの操作するプログラムを作成しているのですが、 たとえば、 out/temp1.jpg … $B$K!#(B, $BB?$/$N%j%s%+! "$=$NEZCO$N(B1$BF|$O(B24$B;~4V$G$O$J$$$3$H$K$bCm0U$9$k$3(B strtok()$B$@$1$G$"$k!#$?$@$7;H$&$K$O%3%D$,$$$k$7! char *$B$rF@$k!#$3$l$OHf3S$K;H$($k!#0J2(B $B$s$GG/!&7n!&F|$N%U%#! $B$N:9$O$I$&$d$C$F7W;;$9$k$N$+!#(B, ANSI/ISO$B5,3J$N(BC$B8@8l$O!"(Bmktime()$B$H(Bdifftime()$B$H$$$&4X?t$r! (B $B%;%9$,5/F0$5$l$kA0$K%7%'%k$K$h$C$F(B $B$F(B($B0lEY$K%a%b%j$KG(B)$B!"%=! 13.7: 正規表現とかワイルドカードを使った比較をするコードが必要となっ た。 A: まず、古典的な正規表現(Unixのedやgrepといったユーティリティーで 使われている)とファイル名のワイルドカード(たいていのオペレーティ ングシステムで使われている)の違いが分かっているかどうか確認す ること。