Hi all,
What i am trying to accomplish is take in a list of IP addresses from a text file (each Ip is on a new line).
I got my program mostly working except when an IP address is longer than the last one it keeps the extra numbers beacuse im having trouble clearing the IP.
What i am trying to accomplish is take in a list of IP addresses from a text file (each Ip is on a new line).
I got my program mostly working except when an IP address is longer than the last one it keeps the extra numbers beacuse im having trouble clearing the IP.
Code:
fd = open("/usr/nodes.ini", O_RDWR);
len = read(fd, buffer, 5000); // Find out how to do dynamic size would be nice.
while(i < 5000)
{
if(buffer[i] == 10){ // check to see if it is a new line.
n=0; // Reset the Ip loop.
printf("Node: %s\n", node);
// Clear Node;
//int y=0;
//while(y < 16){ node[y] = "X"; y++; }
Tried this but nothing would write to node after.
char node[16]; // Tried just to reintialize node but no dice.
memset(node, 0, 16); // Saw this method on the forums but no dice.
i++;
}
else{node[n] = buffer[i]; } // Its not a new line so add to the node Ip.
printf("N=%d | Bufi=%c | Node = %s\n\n",n, buffer[i], node);
n++;
i++;
}
Comment