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