printf vs std::cout and std::ofstream
Hi, am having a bit of difficulties earlier on getting something printed out to screen or file. I don't have the code in front of me so please forgive me if I can't paste the whole piece here. Essentially it's like this.
This works.....
printf("ip address : %s\n", inet_ntop(AF_INET, &(((struct sockaddr_in *)sa)->sin_addr), s, maxlen));
But the following don't.....
std::cout << inet_ntop(AF_INET, &(((struct sockaddr_in *)sa)->sin_addr), s, maxlen);
std:: ofstream ofile("file.txt");
ofile << inet_ntop(AF_INET, &(((struct sockaddr_in *)sa)->sin_addr), s, maxlen);
Any idea why?
|