K
Kees Hoogendijk
Hi everyone,
I've tried for a few day to make a function to check out the zipcode. But it
just doens't work. Can someone help me?
In the zipcode, the figures must be larger than 1000 en the charaters may
not be empty, but when the letter kind is "A", "D" of "F" then the zipcode
may be "0000 ".
TI@,
Wen
#include <iostream>
#include <string>
struct Zipcode
{
int cijfer;
char letter[3];
};
int PostcodeContr(int& juist);
using namespace std;
int main()
{
char soort[2];
Zipcode code;
int goed;
cout<<endl;
cin>>code.cijfer;
cin.getline(code.letter,3);
cout<<"soort :"<<endl;
cin>>soort;
PostcodeContr(goed);
cout<<goed;
cin.get();
cin.get();
}
int PostcodeContr(int & juist)
{
Zipcode pcode;
char soort [2];
//1 is right, 2 is wrong.
if(pcode.cijfer > 1000 && strcmp(pcode.letter," ")!=0)
return juist = 1;
//als soort is gelijk aan A of D of F en postcode="0000 "
else if((stricmp(soort, "A") == 0 || stricmp(soort, "D") == 0
|| stricmp(soort, "F") == 0 )
&& pcode.cijfer == 0 && strcmp(pcode.letter," ")==0)
return juist = 1;
else
return juist = 2;
}
I've tried for a few day to make a function to check out the zipcode. But it
just doens't work. Can someone help me?
In the zipcode, the figures must be larger than 1000 en the charaters may
not be empty, but when the letter kind is "A", "D" of "F" then the zipcode
may be "0000 ".
TI@,
Wen
#include <iostream>
#include <string>
struct Zipcode
{
int cijfer;
char letter[3];
};
int PostcodeContr(int& juist);
using namespace std;
int main()
{
char soort[2];
Zipcode code;
int goed;
cout<<endl;
cin>>code.cijfer;
cin.getline(code.letter,3);
cout<<"soort :"<<endl;
cin>>soort;
PostcodeContr(goed);
cout<<goed;
cin.get();
cin.get();
}
int PostcodeContr(int & juist)
{
Zipcode pcode;
char soort [2];
//1 is right, 2 is wrong.
if(pcode.cijfer > 1000 && strcmp(pcode.letter," ")!=0)
return juist = 1;
//als soort is gelijk aan A of D of F en postcode="0000 "
else if((stricmp(soort, "A") == 0 || stricmp(soort, "D") == 0
|| stricmp(soort, "F") == 0 )
&& pcode.cijfer == 0 && strcmp(pcode.letter," ")==0)
return juist = 1;
else
return juist = 2;
}