input mail

This is a discussion on input mail within the C++ Programming forums, part of the General Programming Boards category; i have function test input mail, but when i have run it, error happen thats Assertion , can you help ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    41

    input mail

    i have function test input mail, but when i have run it, error happen thats Assertion, can you help me, fix it, i dont know fix where.thanks
    Code:
    //CheckerMail.h"
    #include"string"
    using namespace std;
    class CIMail{
    
    public :
    	static bool checkpart1(char &chr);
    	static bool checkpart2(string &str);
    	static bool checkpart3(string &str);
    	//static bool checkpart4(string &str);
    	static int checkchar(string &str);
    
    };
    //CheckerMail.cpp"
    
    #include "string"
    #include <iostream>
    #include "CheckerMail.h"
    using namespace std;
    bool CheckerMail::checpart1(string &par1){
    	if(par1.length()==0)return false;
    	int k=indexdot(par1);
    	for(int i=k+1;i<sizeof(par1);i++)
    		if(check(par1[i])){
    			return true;
    		}
    		return false;
    }
    
    bool CheckerMail::checper2(string &par2){
    	if(par2.length()==0)return false;
    	int h=indexa(par2);
    	int j=indexdot(par2);
    	for(int i=h+1;i<j;i++)
    	if(check(par2[i])||(par2[i]=='.')||(par2[i]=='_')){
    		return true;
    	}
    	return false;
    	//return true;
    }
    //
    bool CheckerMail::checper3(string &par3){
    		if(par3.length()==0)return false;
    	int index=indexa(par3);
    	for(int i=0;i<index;i++)
    		if(check(par3[i])||(par3[i]=='%')||(par3[i]=='+')||(par3[i]=='-')||(par3[i]=='.')||(par3[i]=='_')){
    		return true;
    		}
    	return false;
    }
    //
    int CheckerMail::indexa(std::string &str){
    	for(int i=0;i<sizeof(str);i++){
    		if(str[i]=='@')return i;
    	}
    	return 0;
    
    }
    int CheckerMail::indexdot(std::string &str){
    	int k=0;
    	for(int i=0;i<sizeof(str);i++){
    			if(str[i]=='.')
    				return i;
    	}
    	//return k;
    	return 0;
    
    }
    //@
    bool CheckerMail::check(char &par){
    	if((par>='a')&&(par<='z')||((par>='A')&&(par<='Z')))
    		return true;
    	return false;
    
    }
    //
    bool CheckerMail::checmain(std::string &par){
    	if(!checper2(par)||!checper3(par)||!checpart1(par))return false;
    		return true;
    	//return false;
    
    }
    ///main 
    #include "string"
    #include <iostream>
    #include "CheckerMail.h"
    using namespace std;
    void main(){
    
    string str;
    	cin>>str;
    	cout<<CheckerMail::checmain(str);
    
    }

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    - All of your "#include "string""s should be "#include <string>".
    - "CheckerMail.h" declares some class "CIMail", but that class is never used. You probably want this class to be called "CheckerMail".
    - When you rename the class above, all your signatures will not match any more (not that they do now)--in the header you declare them as static, but in its implementation ("CheckerMail.cpp") they are not static. You probably want them all to be static.
    - Also when you rename the above class, the names of the functions dont even match and you dont have them all declared in the header. Your using stuff like "CheckerMail::checmain" and "CheckerMail::indexa" among a number of other functions that arent declared in the header.
    - In your header the functions are something with the word "part" in it, but your calling some with "part" and some with "per".
    - "void main()" should be "int main(void)", also good idea to add a "return x" at the end of main, for some "int x"

    Basically I have no clue what your doing. What compiler are you using and how were you even able to run this?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked List from Standard Input
    By mercuryfrost in forum C Programming
    Replies: 14
    Last Post: 08-24-2009, 12:05 AM
  2. input redirection
    By sashaKap in forum C Programming
    Replies: 6
    Last Post: 06-25-2009, 01:59 AM
  3. I would love some input on my BST tree.
    By StevenGarcia in forum C++ Programming
    Replies: 4
    Last Post: 01-15-2007, 12:22 AM
  4. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  5. Structure and Linked List User Input Question
    By kevndale79 in forum C Programming
    Replies: 16
    Last Post: 10-05-2006, 11:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21