Hello,
I am a subscribee to the linux-c-programming listserv. I have
tried to send the message there several times during the last few days
with no luck. It's not getting bounced, but I'm not recieving it back in
my mailbox either. Could you please post it for me? (Any maybe answer too?
:)
-=-=-=-==-=-=-=-=-=-=-=-==-=-=-=-==-=-=-=-=-=-==-=-=-==-=-=-=-=-=-=-=
>From [EMAIL PROTECTED] Tue Jun 23 21:22:59 1998
Date: Tue, 23 Jun 1998 21:18:07 -0400 (EDT)
From: Joseph Martin <[EMAIL PROTECTED]>
To: Linux C Programming <[EMAIL PROTECTED]>
Subject: Help with strings, pointers, returns, etc
Hello,
I am struggling with my long time nemesis again - strings in C. I
have a function I'm writing that will read in a file, assign each line to
a subscript in an array, and return the array. Problem is I can't get pass
the returning. Suggestions welcome. Code follows. Thanks a ton.
#include <stdio.h>
#include <stdlib.h>
#include "file.h"
char *read_file()
{
char line[10][80];
int i;
FILE *budget;
if((budget = fopen("/home/martinja/.bashrc", "r"))==NULL) {
printf("Cannot open config file\n");
exit(1);
}
for(i=0; i<10; i++) {
fgets(line[i], 80, budget);
printf("%s", line[i]); // This tests if line reads
// correctly
}
fclose(budget);
return ??? //help here please!
}
Joseph Martin
[EMAIL PROTECTED]
Linux newbie/sysadmin ( dangerous combo! ;-> )
B.T.W. The include file "file.h" just has the declaration for "read_file".