2011-10-27 17 views
-1

imは文字列のインデックス検索を実行しようとしていますが、IMにエラーメッセージが表示されます。const char *からintへの無効な変換。誰かがこれが何を意味するのか説明してください。 PLZ助けると、ここ インデックス検索方法の実行方法

#include <iostream> 

#include<string> 

#include <stdio.h> 
#include <string.h> 

using namespace std; 



void clist(char fn[],char ln[], int size); 



char search_list(const char fn[],const char ln[], int size, string find); 



int main(){ 

    string search; 



    cout << "This program searches a list .\n"; 

const int total = 3; 

char fn[total]; 
char ln[total]; 

clist(fn,ln, total); 

cout << "Search contact:____ "; 

cin >> search; 

search_list(fn,ln, total, search); 



    return 0; 

} 

void clist(char fn[],char ln[], int size){ 

    cout << "Enter " << size << " contact.\n"; 

    for (int index = 0; index < size; index++) 
    cin >> fn[index] >> ln[index] ; 

} 

//どこかにこのコードブロックでは私にエラーを与えているコードですが、私はそれを把握するように見えるカントおかげ char型のsearch_list(のconst char型のFN [] 、のconst char型のLN []、int型のサイズ、文字検索){

int index = 0; 

    while ((fn[index] != search) && (index < size)) 

     index++; 

    if (index == size)//if target is not in a. 

     index = ""; 

    return index; 

} 
+0

コードが多すぎます。受け取ったエラーメッセージをよく見てください。エラーが発生したコード行番号が含まれている必要があります。 – iehrlich

答えて

1

あなたは型の引数を取る関数を呼び出している

const char[], const char[], int, char 
あなたが最後のものが一致していないかを確認することができ、引数

const char[], const char[], int, string 

また、この行でintchar const[]を割り当てるしようとしている:ここで

index = ""; 
0
if (index == size)//if target is not in a. 

    index = ""; 

は誤りである、あなたの指数が整数である、あなたはそれを設定することはできませんchar *型。

+0

ありがとうございますが、間違ったコードを投稿しました。 – user836910

関連する問題