Forgot binary file read :(

Hi I have a file users.txt in server and client send a user name and server checks it, but I can only check the first name. So I open the file as binary

File contains

Karim //I seem to have forgotten how to go to John and kacka
John
Kacka

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

 while(!rw.eof()){
            bool connected=false;
            char usr[strlen(info->buf)];
            rw.read(usr, sizeof(usr));

            if(strcmp(usr, info->buf)==0){

                    if(read_size=send(info->sockfd, info->buf, sizeof(info->buf), 0)>0)
                        cout<<info->buf<<" is now logged on"<<endl;
                        connected=true;

                    }

            if(connected==true)
                break;
            int pos=rw.tellg();
            rw.seekg(pos,ios::end); //?????
        }
Last edited on
I don't understand.
Please look at this code, I want to read the content of info->buf in text format to the server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
if(read_size=recv(info->sockfd, info->buf, sizeof(info->buf), 0)>0)
                    {
                        printf("Message recieved from client\n");

                        wr.open(info->folder/*, ios::binary)*/);
                        //wr.write(info->buf, sizeof(info->buf));
                       int i=0;
                        while(info->buf[i]!='\0'){

                            wr<<info->buf[i];
                            i++;

                        }
                        wr.close();


Binary I can do. but this is writing as binary format , how can I save the file in server in it's original file extension?
You need to send the file name to the server.
Topic archived. No new replies allowed.