I have a file.txt
where I m reading each line and I wan t to handle those lines. The file contains IP, Nicknames and some values. I want to save only the IP addresses to another file, but before that I m checking the result returned by my function (char* get_ip(char arr[])
).
The problem is the returned value, it s showing me only a partial, e.g:
normal IP address: 66.55.44.33
My return: 66.55.44
Edit:
2项职能:main()
和get_ip(
)。
//<----------- FUNCTION get_ip() -------------------- ><br />
char* get_ip(char buff[]){
char line[32];
for(int i = 0; i < sizeof(buff); i++){
if(buff[i] == . ){
if(isdigit(buff[i + 1])){
i = 0;
while(buff[i] != ){
line[i] = buff[i];
i++;
}
break;
}
}
}
if(isdigit(line[0]))
return line;
else
return 0;
}
//<------------ FUNCTION int main() --------------------->
int main(){
// variable, opening folder etc.
char buff[64], *line;
while(!feof(fph)){
fgets(buff, 63, fph);
line = get_ip(buff);
if(line)
cout << line << "
";
}
} // main() func. end