C language to use the strcmp function, how to convert int to char *

topic description

I hope the gods can give me the code

sources of topics and their own ideas

A lookup function that uses the strcmp function to compare

related codes

/ / Please paste the code text below (do not replace the code with pictures)
this is the defined structure

typedef struct snode
{
    int No;            // 
    char Name[20];    // 
    char Gender[5];    // 
    int Cnt;        // 
    LNode *cj;        // 
    char brithday[20];// 
    double Avg;        //
    char party[6];  //
    char phoneNo[15];// 
    char addr[20];    // 
}SNode;
void Search(SNode *a,int Count){
    
        char r[20];
    strcpy(r,"1");
    
    if(Count==0)
                cout<<""<<endl;
            
            else{
                int sel;
                do{
                    system("CLS");
                    menu2(); 
                    cin>>sel;
                    system("CLS");
                
                    if(sel==1) do{
                        
                        int flag=0;    
                        cout<<",0"<<endl;
                        cin>>r;
                        for(int j=0;j<Count;jPP)
                        
                            if(strcmp(a[j].No,r)==0){
                                cout<<a[j].No<<" "<<
                                a[j].name<<" "<<
                                a[j].gender<<" "<<
                                a[j].brithday<<" "<<
                                a[j].phoneNo<<" "<<
                                a[j].party<<" "<<
                                a[j].addr<<endl;
                            
                                flag=1;}
                                
                        if(!flag)
                        cout<<""<<endl;
                    }while(strcmp(r,"0")!=0);
                    else if(sel==2)
                        do{
                            strcpy(r,"1");
                            int flag=0;
                            cout<<"0"<<endl;
                            cin>>r;
                            for(int j=0;j<Count;jPP)
                            if(strcmp(a[j].name,r)==0){
                                cout<<a[j].No<<" "<<
                                a[j].name<<" "<<
                                a[j].gender<<" "<<
                                a[j].brithday<<" "<<
                                a[j].phoneNo<<" "<<
                                a[j].party<<" "<<
                                a[j].addr<<endl;
                                
                                flag=1;}
                                
                        if(!flag)
                        cout<<""<<endl;
                        }while(strcmp(r,"0")!=0);
                    else if(a==0)
                        break;
                    else{
                        cout<<""<<endl;
                        system("pause"); }
                }while(1);}
                break;
}

what result do you expect? What is the error message actually seen?

it"s mainly the error of strcmp

C
Apr.16,2021

the following is the function,
{

// num: src num; base: max is hex(16) ; str: dst str
int32_t me_uint64_to_str(uint64_t num, uint8_t base, char *str, int str_len)
{
    char tmp_str[32] = {0};
    int tmp_num = num;
    int i = 0;
    int tmp_len = 0;
    char tmp_ch = 0;

    if (base > 16)
    {
        // err("not support base\n");
        goto fail;
    }

    while (num)
    {
        tmp_num = num % base;
        tmp_str[i]= "0123456789ABCDEF"[tmp_num];
        num /= base;
        iPP;
    }
    tmp_len = strlen(tmp_str);
    for (i = 0; i < tmp_len/2; iPP)
    {
        tmp_ch = tmp_str[i];
        tmp_str[i] = tmp_str[tmp_len-1-i];
        tmp_str[tmp_len-1-i] = tmp_ch;
    }

    if ((tmp_len + 1) > str_len)
    {
        // err("str is too short\n ");
        goto fail;
    }
    memcpy(str, tmp_str, strlen(tmp_str) + 1);

    return 0;
fail:
    return -1;
}

}

here are examples of use:
char tmp_str [20] = {0};
int tmp_num = 10;
me_uint64_to_str (num, 10, tmp_str, strlen (tmp_str));
cout < < "result" < < tmp_str < < endl;

)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35ffd-2bfc2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35ffd-2bfc2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?