samedi 1 juillet 2017

I'm getting invalid conversion from char to const char error.How to fix this program?

I'm getting this error in few lines and don't know how this program would work.Begineer programmer here.Any help would be appreciated.

#include<iostream>
#include<cstring>
using namespace std;
char* find_greater(char* a,char b)
{
    char* result;
    if(strcmp(a,b)>0) 
        result=a;  
    else
        result=b;
    return result;
}
int main()
{
    char str1[10],str2[10];
    str1[]="zebra";
    str2[]="man";
    cout<<"Greater string is :"<<find_greater(str1,str2)<<endl;
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire