Hiya, I dont know if I am in the correct forum i.e. Networking. I am having problems with Server / Client communication.

I send data over to the client and it records and prints out in cout, but what I want to do is print in a file.

I used

double x;

and then called

bool getPosition(x);

if (whatever.getPosition(x)) {

//

}

 while (whatever.getposition(x)){ 
 

cout << x

}


file buffer;
ostream output(&buffer);
buffer.open("xxxxxxxxxxx.txt",ios::in| io::out| ios::trunc);

for (int i=1; i<=20;i++){

output << i<< x ; // where x is the value that is recorded

}

but it just prints out one value at a time. If you need more code please let me know

Cheers

Variable x is not being changed inside that loop, so it will print the same value of x to the file 20 times.