Results 1 to 4 of 4

Thread: Compare chatacter to another?

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    ON, CAN
    Posts
    265

    Compare chatacter to another?

    i feel like such an amature again... what i'm trying to accomplish is to find the preriods in an ip address.

    Code:
    #include<string.h>
    #include<iostream.h>
    #include<conio.h>
    
    void main()
    {
    	void return_class(char ip[]);
    	char ip[] = {"155.25.54.1"};
    	return_class(ip);
    
    
    }
    void return_class(char ip[])
    {
    	int sLength;
    	char firstoctet[4];
    
    	// get string length
    	sLength = strlen(ip);
    	
    	// loop character array retrieving all characters the 
    	// preceed the first period character
    
    	for(int x = 0; x < sLength; x++)
    		if(ip[x] == ".")
    			cout<<"period"<<endl;
    	getch();
    }
    i've also try tried the strcmp() functioins but all i get is cannot covert from char to char*

    Code:
    if(strcmp(ip[x], ".") == 0)
    no go there! how can i loop through a character array and compare that character with another?

    Thank, (so frustrating, when its so simple in vb)

    Regan
    Last edited by MOHH; Apr 18th, 2002 at 03:28 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width