Article View: alt.comp.lang.learn.c-c++
Article #301char array compare
From: EL
Date: Fri, 25 Jan 2002 17:10
Date: Fri, 25 Jan 2002 17:10
46 lines
1754 bytes
1754 bytes
Help!
How can i compare a char array from defined structure with input char?
I can't get the expected result from the following coding. Pls help!
struct mystr
{
char id[7], name[21];
};
mystr s[50];
void main()
{
int i, j ;
char vid[7];
for (i=0; i<2 ; i++)
{
cout << "Stud ID : ";
cin >> s[i].id;endl;
cout << "Name : ";
cin >> s[i].name;endl;
}
for (i=0; i<2 ; i++)
{
cout << "ID: " << s[i].id << "\t" << "Name: " << s[i].name << endl;
}
cout << "\nEnter search id: ";
cin >> vid;endl;
for (i=0; i<2 ; i++)
{
if (vid == s[i].id)
{
cout << "\nFound id: " << s[i].id;
}
else
{
cout << "\nNot found you id " << vid;
}
}
}
Technical Details
Message-ID:
<a2s339$ngo3@imsp212.netvigator.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!newsgate.cuhk.edu.hk!newsgate.netvigator.com!imsp212.netvigator.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f8d38,70272e41ccb8f8b6,start X-Google-Attributes: gidf8d38,public X-Google-Thread: 109fba,70272e41ccb8f8b6,start X-Google-Attributes: gid109fba,public X-Google-Thread: 114592,70272e41ccb8f8b6,start X-Google-Attributes: gid114592,public X-Google-ArrivalTime: 2002-01-25 09:06:02 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!newsgate.cuhk.edu.hk!newsgate.netvigator.com!imsp212.netvigator.com!not-for-mail From: "EL" <lameddie@yahoo.com> Newsgroups: alt.comp.lang.learn.c-c++,borland.public.cpp.language,comp.lang.c++ Subject: char array compare Date: Sat, 26 Jan 2002 01:10:24 +0800 Organization: IMS Netvigator Lines: 48 Message-ID: <a2s339$ngo3@imsp212.netvigator.com> NNTP-Posting-Host: pcd262100.netvigator.com X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000