私は大学のコースのプログラムを作成するように求められており、ファイル内の空白と閉じた括弧の数を確認する必要があります。FILE * -C++を変換できません
40:22:私は私の機能のための2つのエラーメッセージ取得しています引数は 'のconstのchar *' に変換することはできませんFILEの* {aka_IO_FILE *}を '1' FILE *
FPINの=ののfopen(FPIN)。
42:22:警告フォーマット '%s'は 'char *'型の引数を必要としますが、引数2は 'int型'を持ちます printf( "%s \ n"、arr [1])を開くことができませんでした。
void countBrackets(char arr[])
{
int bracketCount = 0:
int lineNumber = 0;
//tracking position in file
FILE* fpin;
//open file and check to make sure
//file opened safley
fpin = fopen(fpin);
if (fpin == NULL){
printf("Could not open %s \n", arr[1]);
return;
}
//Count how many opened and closed { and } brackets are
//in the file
for (char currCh = 0; currCh > lineNumber; currCh ++){
if (currCh == '{') {
bracketCount ++;
}else if (currCh == '}') {
bracketCount ++;
}else (currCh == '\n') {
lineNumber ++;
}
//display error messages for the user
if (bracketCount < 0) {
printf("there is more closing brackets than opening\n");
}else{
printf("There is more opening brackets than closing\n");
}
}
fclose(fpin);
}
...それはコンパイルするための十分なはずです。その最初のパラメータは 'const char *'でなければなりません。 'arr'は配列なので、' arr [1] 'は' char'で、 '%s'フォーマットの指定には' const char * '値が必要です。 –