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: David M. <dem...@uw...> - 2003-04-09 17:00:20
|
Gahh, stupid stupid.
At 09:27 AM 09/04/2003 -0400, David Matthews wrote:
>Looks like what you actually want is something like this:
>
>char *FileContent(file *fp)
>{
> char *buf;
> // Open the file...
> int i =3D fseek(fp, SEEK_END) + 1;
> buf =3D malloc(sizeof(i));
Should be malloc(i); instead :\
> fseek(fp, SEEK_SET);
> for(char ch =3D fgetc(fp); ch !=3D EOF; buf++ =3D 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 =3D 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=E9
>>
>>
>>
>>
>>-------------------------------------------------------
>>This SF.net email is sponsored by: ValueWeb:=20
>>Dedicated Hosting for just $79/mo with 500 GB of bandwidth!=20
>>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
>>
>
>
>-------------------------------------------------------
>This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger=
=20
>for complex code. Debugging C/C++ programs can leave you feeling lost and=
=20
>disoriented. TotalView can help you find your way. Available on major UNIX=
=20
>and Linux platforms. Try it free. www.etnus.com
>_______________________________________________
>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
>
|