私の質問についてはすでにあまりにも多くの質問があることを認識していますが、これまでに見た回答は、ポインター、int
値になる関数の戻り値を想定しています。
と の 2 つの関数がvoid binarycheck(int encoding, product *curr[], int totalcurr)
ありvoid search_show()
ます。
binarycheck
基本的に、指定encoding
された配列構造体から値を取得しますcurr
(curr には、文字列と int の混合変数が含まれます)。その目的は、ビットごとの関数を介して各配列の curr をcurr
チェックした後、配列を 3 つの主要なタイプと 5 つのサブクラスに分類することです。encoding
サブクラスは、 を形成するために使用された typedef 構造体に含まれていますcurr
。お気に入り:
typedef struct nodebase{
char name[254];
char company_name[254];
int encoding;
double price;
struct nodebase *next;
struct nodebase *Class;
}product;
ここで、binarycheck
関数を使用した後、void search_show
基本的にユーザーに好みの 1) タイプ、2) サブクラスを尋ねvoid search_show
、ユーザーが選択したタイプとサブクラスとして分類された製品を印刷します。
そのため、int (分類された各配列の存在をカウントするため) および配列 (データを分類するため) の形式のvoid search_show
結果を使用する必要があります。void binarycheck
void binarycheck
によって使用されるすべての変数をパラメーターとして配置することにより、「力ずく」の方法を考えてvoid search_show
いましたが、変数が多すぎて追加できません。
すべての変数と最初の関数の結果を 2 番目の関数で "再利用" する方法を教えてもらえますか?
*WindowsでTiny Cを使用しています
サンプル コード: //Binarycheck には、以下に示す変数が含まれます。
void *binarycheck(int encoding, hero *curr[], int totalwarrior)
{
int toughtotal = 0;
int nimbletotal = 0;
int smarttotal = 0;
int skeptictotal = 0;
int mystictotal = 0;
int cursedtotal = 0;
int brutetotal = 0;
int shreddertotal = 0;
int vanillatotal = 0;
int typetotal = 0;
int class_num = 0;
int class_total[6];
int total = 0;
hero *type[3][6] = {{0},{0}};
hero *smart[3][6] = {{0},{0}};
hero *nimble[3][6]= {{0},{0}};
hero *tough[3][6]= {{0},{0}};
hero *skeptic[]= {0};
hero *mystic[]= {0};
hero *cursed[]= {0};
hero *brute[]= {0};
hero *shredder[]= {0};
hero *vanilla[]= {0};
//This is a sample of assigning "curr[totalwarrior]' into its respective type array.
if ((encoding&128)==1 && (encoding&64)==1)
{
smart[smarttotal][class_num] = curr[totalwarrior]; //class_num is 0 as of this moment.
total = smarttotal;
type[total][class_num] = smart[smarttotal][class_num];
smarttotal++;
printf("\n::|Smart Type::|\n");
}
/*There will be 2 more of this code (above) since there will be 3 types array*/
//This is assigning "type[total][class_num]" into its respective class array.
if ((encoding&32)==1)
{
class_num = 1;
type[total][class_num] = vanilla[vanillatotal];
class_total[1] = vanillatotal;
vanillatotal++; //Vanilla
printf("\n::|Vanilla Class::|\n");
}
/*There will be 5 more of this code (above) since there will be 6 class array*/
、、、seach_show
を使用する必要がtotal
ありclass_num
ますtype[total][class_num]
class_total