Comparing

This is a discussion on Comparing within the C++ Programming forums, part of the General Programming Boards category; Hi, Im trying to compare a char* (vsDni) with the data from a text box. Here is a sample of ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    29

    Unhappy Comparing

    Hi,

    Im trying to compare a char* (vsDni) with the data from a text box.

    Here is a sample of the code.


    Code:
    int dni;
    
    TCHAR cDni[20];
    
    dni= IsDlgButtonChecked(u_hDlg,IDC_CHECK_DNI);
    
    
    else if (dni==1)
    		{
    			int item_txt_dni = GetDlgItemText(u_hDlg, IDC_DNI, cDni, 20);
    			
    			if (strcmp(vsDNI, cDni) == 0)
    			{
    				sprintf(sOutput, " %-3.3d Make call %s %s ", viLine, vsANI, vsDNI);
    				vLog(sOutput);
    			}
    		}
    So if the two are equal then do the print statement.

    Doesnt seem to be working!

    Is this the best way to do this?
    If not can anyone suggest a better way?

    Any help whatsoever would be great,

    thanks a lot,



  2. #2
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    > else if (dni==1)

    doesn't appear to be correct. Else what?

    Should not compile anyway. Unless you have not pasted the complete code.

    Where do you declare & set vsDNI?

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    29
    Hi,

    ok here is the whole code, ive tried to put the relevant code in orange! Dont know if it worked, if not just read previous post!


    Code:
    
    void LogData(int viLine, char* vsANI, char* vsDNI)
    {
    		int err44;
    		int line;
    		int cli;
    		int dni;
    		int errs;
    
    		int cCli;
    		TCHAR cDni[20];
    
    
    		//char test[100];
    
    		char sOutput[100];
    
    		err44= IsDlgButtonChecked(u_hDlg,IDC_CHECK1);
    		line= IsDlgButtonChecked(u_hDlg,IDC_CHECK_LINE);
    		cli= IsDlgButtonChecked(u_hDlg,IDC_CHECK_CLI);
    		dni= IsDlgButtonChecked(u_hDlg,IDC_CHECK_DNI);
    		errs= IsDlgButtonChecked(u_hDlg,IDC_CHECK_ERRS);
    
    		if(err44==1)
    		{
    			
    		}
    		
    		else if (line==1)
    		{
    			int iLineToShow = GetDlgItemInt(u_hDlg, IDC_LINE, NULL, TRUE);
    			if (iLineToShow == viLine)
    			{
    				sprintf(sOutput, " %-3.3d Make call %s %s ", viLine, vsANI, vsDNI);
    				vLog(sOutput);
    			}
    
    		}
    
    
    		else if (cli==1)
    		{
    			int item_txt_cli = GetDlgItemInt(u_hDlg, IDC_CLI, cCli, TRUE);
    			if (vsANI == cCli)
    			{
    				sprintf(sOutput, " %-3.3d Make call %s %s ", viLine, vsANI, vsDNI);
    				vLog(sOutput);
    			}
    		}
    
    		else if (dni==1)
    		{
    			int item_txt_dni = GetDlgItemText(u_hDlg, IDC_DNI, cDni, 20);
    			
    			if (strcmp(vsDNI, cDni) == 0)
    			{
    				sprintf(sOutput, " %-3.3d Make call %s %s ", viLine, vsANI, vsDNI);
    				vLog(sOutput);
    			}
    		} 
    		
    
    		else if (errs==1)
    		{
    			
    		}
    		
    		
    		else
    		{
    			sprintf(sOutput, " %-3.3d Make call %s %s ", viLine, vsANI, vsDNI);
    			vLog(sOutput);
    		}
    
    
    		sprintf(sOutput, "cDni is <%s> ", cDni);
    		vLog(sOutput);
    
    }
    Anything else you need for you to help me just ask!

    Thanks again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. comparing data in two files
    By nynicue in forum C Programming
    Replies: 25
    Last Post: 06-18-2009, 08:35 PM
  2. Replies: 2
    Last Post: 04-29-2009, 11:13 AM
  3. Problem with comparing strings!
    By adrian2009 in forum C Programming
    Replies: 2
    Last Post: 02-28-2009, 10:44 PM
  4. bit vs bytes when comparing a file
    By Overworked_PhD in forum C Programming
    Replies: 6
    Last Post: 05-20-2007, 12:22 AM
  5. comparing problem
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 03-05-2002, 06:19 AM

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