题目的第1条需求和第5条需求有点冲突吧?不管怎样请看下面的代码 。
ubuntu 10.10 自带的编译器
编译器版本 gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5.1)
#include
#include
using namespace std;
//check the issue of '@'
int checkmark(char * address);
//check the the char before and behind the first '@'
int checkfirstmarkbeforandbehind(char * address);
//check the issue of '.'
int checkdot(char * address);
//check that dot is not at the first and last place.
int checkdotendandbefore(char * address);
//check the char in the mailladdress is the valid
int checkcharvalid(char * address);
int main(){
char emailaddress[200];
memset(emailaddress,sizeof(emailaddress),0x00);
cout<<"Please input the address"<
if(!checkcharvalid(emailaddress)){
cout<<"the address contain the valid char !!!"<
}
if(!checkmark(emailaddress)){
cout<<"the format of address is error(@) !!!"<
}
if(!checkdot(emailaddress)){
cout<<"the format of address is error(.) !!!"<
return 0;
}
int checkmark(char *address){
char * mark = NULL;
if(!checkfirstmarkbeforandbehind(address)){
cout<<"@ error "<
}
if(!(mark =strchr(address,'@'))){
return 0;
}
mark ++;
if(strchr(mark,'@')){
return 0;
}
else{
return 1;
}
}
int checkdot(char * address){
char * dot = NULL;
if(!checkdotendandbefore(address)){
return 0;
}
while((dot = strchr(address,'.'))){
address = dot + 1;
if(*address == '.'){
return 0;
}
}
return 1;
}
int checkdotendandbefore(char * address){
if(*address == '.'){
return 0;
}
if(address[strlen(address)-1] == '.'){
return 0;
}
return 1;
}
int checkfirstmarkbeforandbehind(char * address){
char * mark = NULL;
mark = strchr(address,'@');
if(!mark){
return 0;
}
if(*mark == *address){
return 0;
}
if(address + strlen(address)-1 == mark){
return 0;
}
return 1;
}
int checkcharvalid(char * address){
int flage = 0;
for(int i = 0; i < strlen(address); i++ ){
char temp = address[i];
if((temp >= '0' && temp <= '9') || (temp >= 'a' && temp <= 'z' ) || (temp >= 'A' && temp <= 'Z') || temp == '.' || temp == '_' || temp == '@'){
continue;
}
else{
return 0;
}
}
return 1;
}
FARPROC GetProcAddress( HMODULE hModule,LPCSTR lpProcName);
你在调用dll里面的函数时,总要先获取这个函数。GetProcAddress里面的hModule就指明了你要从哪个动态库里获取这个函数。也就是说,你这个函数是从哪个dll里面加载的,调用的就是哪个dll里面的函数。
但愿能帮到你,希望采纳!