I am making a game and i want to to have multi player support.

What i mean is that....

When you load from the save file, you have to write the file name right?
Eg.

FILE *out;
   out = fopen("datafile.dat", "r+b");

How can you let the player choose which file they want to load?

OR

Are there another way that you can have multi player support?

Recommended Answers

All 7 Replies

That's more like multi-profile support, rather than multi-player support.

For what you want, just prompt the user for the filename they want to load, rather than hard-coding "datafile.dat" in the source code.

or you could pass in the name of the file on the command line

int main (int argc, char **argv)
{
    char filename[MAX_FILENAME_LEN];
    
    if (argc>1)
        strcpy(filename,argv[1]);
    else
        strcpy(filename,"default.dat");

    if (fopen(filename,"r+b") == NULL)
    {    
        printf("file <%s> does not exist!\n",filename);
        exit(0);
    }
    
    ...

}

Hmm ok. I kinda get it.
Is there ways to use network?

yes, there are ways to use network.

it's called socket descriptors.. But trust me, if you just only "kinda get" how to read a .DAT file from a local drive... well, you don't want to go there just yet.


.

you want to know how? it's all quite well documented.

go here, here, and here

or, if you must, here

have fun


.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.