C言語なら俺に聞け(入門編)Part 68
■ このスレッドは過去ログ倉庫に格納されています
0091デフォルトの名無しさん
2010/08/24(火) 00:58:30#include <stdio.h>
#define _swap(type, _x, _y) do {type* x=_x; type* y=_y; type t; t=*x; *x=*y; *y=t; } while (0);
void p(char* a, char* b){printf("%s\n%s\n\n",a,b);}
void main(void) {
char a[100]="aiueo1234";
char b[100]="ABCDE5678";
p(a,b);
int i=5; char *ap=a, *bp=b;
while(i-->0){_swap(char, ap++, bp++);}
p(a,b);
}
// 結果
aiueo1234
ABCDE5678
ABCDE1234
aiueo5678
■ このスレッドは過去ログ倉庫に格納されています