473,511 Members | 16,849 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

48 New Member
#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<strlen(p.a);i++)
{
if(p.a[i]==q.b[i])
{
count++;
}
if(count==strlen(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;
}
Nov 16 '14 #1
1 1173
weaknessforcats
9,208 Recognized Expert Moderator Expert
Functions require types or pointers for arguments.

Expand|Select|Wrap|Line Numbers
  1. void  fun(char p.a[], char q.b[])
  2.  
p.a[] is not a type nor is it a pointer.

Change this to:


Expand|Select|Wrap|Line Numbers
  1. void  fun(char* p, char* q) etc... 
Of course, when you do this you will need to make other changes within the function code.
Nov 16 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
76515
by: J.W. | last post by:
How do I compare strings in javascript? The "==" double equals or "!=" doesn't seem to work in this case. I'm sure string comparison has been explained before but searching Google didn't find...
10
7355
by: Lakshmi Narayanan.R | last post by:
Hi Experts, Using keyword "To" in select case giving error.The following code is got from www.microsrosoft.com itself. What is the wrong with this?. <% Dim Number1 Number1 = 7 ' Initialize...
1
2054
by: Edward S | last post by:
Friends, I had posted this on "Microsoft.Public.Access", But I did not get a satisfactory response. I have been struggling for nearly 2 days trying to crack this code. I really need help, could...
3
8880
by: Kiran B. | last post by:
Hi, I am new to .net. I have two Data Structure Type ... Sturcture A and Structure B. Structure A Public Fname as String Public LastName as String Public City as String Public Zip as String...
0
2287
by: Diego Martins | last post by:
Hi! The following code snippet: namespace { bool charCompare(char a, char b) { return tolower(a) < tolower(b); } } bool compareString(const std::string & s1, const std::string & s2) {
6
5307
by: Lawrence Spector | last post by:
I ran into a problem using g++. Visual Studio 2005 never complained about this, but with g++ I ran into this error. I can't figure out if I've done something wrong or if this is a compiler bug. ...
21
35477
by: Ram Prasad | last post by:
I am trying to write a simple libspf2 plugin code for my postfix ( milter) I am getting this unhelpful error message when I try to compile gcc -g1 -Wall -I/usr/local/include/spf2 -I. -c mfunc.c...
1
1459
by: Rahul Bhate | last post by:
Hello Sir My problem is in dos giving error that javac is not recognised.Tell me the steps for debugging.I have already set the CLASSPTH through command line & also set the PATH.But still giving...
1
10207
by: lovecreatesbea... | last post by:
In the following function `HardwareStatusDb()', If its arguments are declared as type of `string', I get: main.cpp:5: error: expected initializer before ‘int’. The error disappears when those...
1
3291
by: rameshjumgam | last post by:
i am having in my code like std::list<T*>::const_iterator iter=lst.begin(); and i am getting error error: expected `;' before âiterâ /root/INCLUDE/cw/gdlist.h:140: error: âiterâ was...
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7423
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5668
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1576
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
447
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.