Hey, Been a while since I posted here. Right now i'm designing a program that checks a socket and see's if the webpage is down or not. If its down i'm going to launch the application. However i'd like it to be more flexible, so i'm working on loading a "config" file into the program containing the address, port and path to the program.
I'd like it to be a seperate function, but i'm curious how I could pass all that info back into the main function. This is my code so far, and i've got as far as the return call, but I don't think you can use multiple returns for each value. So i'm kind've stumped. This is fairly routine stuff i'm sure, but i'm self-taught. So the simple things are usually what gets me.
Code:
void load_config( void )
{
FILE_DATA * fp;
int cnt;
char buffer[5000];
char * host;
char * path;
int port;
if (( fp = fopen("config.txt", "rb" )) == NULL )
{
perror("no config found.");
return 0;
}
for ( cnt = 0; cnt < 3; cnt++ )
{
while ( buffer = fgetc( fp ) ) != EOF )
{
host = str_dup( buffer );
port = str_dup( buffer );
path = str_dup( buffer );
}
}
how to return the info?
}