ショートカット
ファシリテーター × あり方
コーディングの向こう側
Hello, ANOTHER world!
オブジェクト指向のはなし
プログラミングのはなし
C言語実力診断クイズ
eSkillBooks
C言語実力診断クイズ

次のプログラムには誤りがあります。どこでしょう?

#include <string.h>
#include <ctype.h>

#define MAX_CONVERT_LENGTH 100

const char *ConvertToUpper( const char *pcLower )
{
    char Upper[ MAX_CONVERT_LENGTH + 1 ];
    
    const char *pc = pcLower;
    int nUpperIdx = 0;
    for ( ; *pc!='\0'; pc++ ) {
        if ( nUpperIdx < MAX_CONVERT_LENGTH ) {
            Upper[nUpperIdx] = toupper( *pc );
            nUpperIdx++;
        }
        else {
            break;
        }
    }
    Upper[nUpperIdx] = '\0';
    
    return Upper;
}

<< 問題一覧に戻る

(「C言語実力診断クイズ」は2001年5月から9月にかけて作成されたコンテンツです。)