compare 2 strings in structure using function it is giving error: expected ‘;’, ‘,’ o

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jinnejeevansai
    New Member
    • Nov 2014
    • 48

    compare 2 strings in structure using function it is giving error: expected ‘;’, ‘,’ o

    #include<stdio. h>
    #include<string .h>
    struct div1
    {
    char a[50];
    };
    struct div2
    {
    char b[50];
    };
    void fun(char p.a[],char q.b[])
    {
    int i,count=0;
    if(strlen(p.a)! =strlen(q.b))
    {
    printf("n");
    }
    else
    {
    for(i=0;i<strle n(p.a);i++)
    {
    if(p.a[i]==q.b[i])
    {
    count++;
    }
    if(count==strle n(p.a))
    {
    printf("y");
    }
    else
    {
    printf("n");
    }
    }
    int main()
    { struct div1 p;
    struct div2 q;
    scanf("%s",&p.a );
    scanf("%s",&q.b );
    fun(p.a,q.b);
    return 0;
    }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Functions require types or pointers for arguments.

    Code:
    void  fun(char p.a[], char q.b[])
    p.a[] is not a type nor is it a pointer.

    Change this to:


    Code:
    void  fun(char* p, char* q) etc...
    Of course, when you do this you will need to make other changes within the function code.

    Comment

    Working...