How to utilize internal file.

M

monari

Hi everyone!
Can someone tell me if it is possible to use the file operators on a
constant string? And if so, how?
Thx so much!

Giuseppe
 
R

Richard Heathfield

[email protected] said:
Hi everyone!
Can someone tell me if it is possible to use the file operators on a
constant string?

C doesn't have any file operators, so no, it's not possible. If you want to
read data from a string rather than from a stream, simply copy what you
want from the string. Easy.
 
S

santosh

Hi everyone!
Can someone tell me if it is possible to use the file operators on a
constant string? And if so, how?
Thx so much!

There is nothing called "file operators" in C. C implements files
through streams. Writing a string to a stream or reading from a string
to construct a string are trivial. Please give more details for better
responses.
 
S

SM Ryan

[email protected] wrote:
# Hi everyone!
# Can someone tell me if it is possible to use the file operators on a
# constant string? And if so, how?

stdio does not generally allow this. Some implementations, but in general,
no.
 
K

Keith Thompson

Can someone tell me if it is possible to use the file operators on a
constant string? And if so, how?

As others have mentioned, C has no file operators. Operations on
files are performed using function calls.

I *think* you're asking about how to treat an in-memory string as if
it were a file. There is no general mechanism for doing this, but
there are equivalents for certain specific functions; see sprintf and
sscanf, for example.

(Note that the form and meaning of the filename argument to fopen()
are implementation-defined. Conceivably an implementation could
provide a form of filename that refers to a string or other in-memory
buffer. I'm not aware of any implementations that do this.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top