Re: [Dev-C++] passing the content of a string to a variable from
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: jose i. c. <ji...@fr...> - 2003-04-10 01:29:57
|
Yep. I had the other stuff, but was missing the char *FileContent....
thanks,
jose
----- Original Message -----
From: "David Matthews" <dem...@uw...>
To: "jose isaias cabrera" <ji...@fr...>;
<dev...@li...>
Sent: Wednesday, April 09, 2003 9:27 AM
Subject: Re: [Dev-C++] passing the content of a string to a variable from
Looks like what you actually want is something like this:
char *FileContent(file *fp)
{
char *buf;
// Open the file...
int i = fseek(fp, SEEK_END) + 1;
buf = malloc(sizeof(i));
fseek(fp, SEEK_SET);
for(char ch = fgetc(fp); ch != EOF; buf++ = ch);
return buf;
}
I think this should work at least. The code is off the top of my head and
untested.
At 09:51 PM 08/04/2003 -0400, jose isaias cabrera wrote:
>
>Greetings O SmartOnes!
>
>I have the following c code:
>
>char FileContent(char *file)
>{
> char fcontent(3000);
> ...
> /*in here I grab the content of a text file */
> ...
> return(fcontent);
>}
>
>int main(int argc, char *argv[])
>{
> char text[3000];
> ...
> ...
> ...
> text = FileContent("temp.txt");
>}
>
>I can't get this to work. I've a bunch of places and I even tried to get
>the pointers to no avail. I am new to c, but I am an expert programmer.
>Any c help will be greatly appreciated.
>
>thanks.
>
>josé
>
>
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: ValueWeb:
>Dedicated Hosting for just $79/mo with 500 GB of bandwidth!
>No other company gives more support or power for your dedicated server
>http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|