授業/C言語基礎/タイピング・ゲーム のバックアップソース(No.1)

*文字列の比較 [#i7591004]

string.h には、文字列を比較するstrcmp関数が用意されています。

#geshi(c){{
#include <stdio.h>
#include <string.h>

int main(void) {
  char s1[256], s2[256];

  printf("メール・アドレスを入力してください:\n");
  scanf("%s", s1)

  printf("もう一度入力してください:\n");
  scanf("%s", s2)

  if (strcmp(s1, s2) == 0) {
    printf("OK\n");
  } else {
    printf("NG\n");
  }

  return 0;
}
}}
トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS