C with variable -length and ram question....

Discussion in 'C Programming' started by uche, Mar 6, 2007.

  1. uche

    uche Guest

    Hello all! I have thought about this question for a long time and I
    would like to know your opinion about it: In C, a variable-length
    string can be carried in RAM as a sequence of ASCII characters
    followed by a NULL character. Would this work in a disk field? What
    are some considerations to be aware of?
     
    uche, Mar 6, 2007
    #1
    1. Advertising

  2. "uche" <> wrote in message
    > Hello all! I have thought about this question for a long time and I
    > would like to know your opinion about it: In C, a variable-length
    > string can be carried in RAM as a sequence of ASCII characters
    > followed by a NULL character. Would this work in a disk field? What
    > are some considerations to be aware of?
    >

    "What are some considerations to be aware of?" is not normal English.

    It is professorese.

    Your attempt to have homework done is detected and flagged.
     
    Malcolm McLean, Mar 6, 2007
    #2
    1. Advertising

  3. On Mar 6, 10:58 am, "uche" <> wrote:
    > Hello all! I have thought about this question for a long time and I
    > would like to know your opinion about it: In C, a variable-length
    > string can be carried in RAM as a sequence of ASCII characters
    > followed by a NULL character. Would this work in a disk field? What
    > are some considerations to be aware of?


    What is a "disk field"? I have a storage pool outside my office
    window, but I've never seen a disk field.
     
    J. J. Farrell, Mar 6, 2007
    #3
  4. uche

    CBFalconer Guest

    "J. J. Farrell" wrote:
    > "uche" <> wrote:
    >
    >> Hello all! I have thought about this question for a long time and I
    >> would like to know your opinion about it: In C, a variable-length
    >> string can be carried in RAM as a sequence of ASCII characters
    >> followed by a NULL character. Would this work in a disk field?
    >> What are some considerations to be aware of?

    >
    > What is a "disk field"? I have a storage pool outside my office
    > window, but I've never seen a disk field.


    wheat grows in wheat fields
    corn grows in corn fields
    hay grows in hay fields
    poppies grow in poppy fields
    disks grow in disk fields.

    QED. See Wordsworth for daffodil fields.

    --
    <http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
    <http://www.securityfocus.com/columnists/423>

    "A man who is right every time is not likely to do very much."
    -- Francis Crick, co-discover of DNA
    "There is nothing more amazing than stupidity in action."
    -- Thomas Matthews
     
    CBFalconer, Mar 7, 2007
    #4
  5. In article <>,
    CBFalconer <> wrote:

    >wheat grows in wheat fields
    >corn grows in corn fields
    >hay grows in hay fields
    >poppies grow in poppy fields
    >disks grow in disk fields.


    Magnets produce magnetic fields, electricity produces electric fields, ...

    -- Richard
    --
    "Consideration shall be given to the need for as many as 32 characters
    in some alphabets" - X3.4, 1963.
     
    Richard Tobin, Mar 7, 2007
    #5
  6. uche

    santosh Guest

    uche wrote:
    > Hello all! I have thought about this question for a long time and I
    > would like to know your opinion about it: In C, a variable-length
    > string can be carried in RAM as a sequence of ASCII characters
    > followed by a NULL character.


    In C, there's no such thing as a "variable length" string, as opposed
    to fixed length string. The C standard does not specify a particular
    character set, like ASCII, and it doesn't define RAM.

    > Would this work in a disk field? What
    > are some considerations to be aware of?


    Yes strings can be written to a disk file, and read back in with
    fprintf and fscanf among other functions.
     
    santosh, Mar 7, 2007
    #6
  7. "santosh" <> writes:
    > uche wrote:
    >> Hello all! I have thought about this question for a long time and I
    >> would like to know your opinion about it: In C, a variable-length
    >> string can be carried in RAM as a sequence of ASCII characters
    >> followed by a NULL character.

    >
    > In C, there's no such thing as a "variable length" string, as opposed
    > to fixed length string. The C standard does not specify a particular
    > character set, like ASCII, and it doesn't define RAM.
    >
    >> Would this work in a disk field? What
    >> are some considerations to be aware of?

    >
    > Yes strings can be written to a disk file, and read back in with
    > fprintf and fscanf among other functions.


    At the risk of doing part of the OP's homework, text written to a file
    is typically in the form of lines (terminated by '\n'), not strings
    (terminated by '\0').

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Mar 7, 2007
    #7
  8. Keith Thompson said:

    > "santosh" <> writes:
    >> uche wrote:
    >>> Hello all! I have thought about this question for a long time and I
    >>> would like to know your opinion about it: In C, a variable-length
    >>> string can be carried in RAM as a sequence of ASCII characters
    >>> followed by a NULL character.

    >>
    >> In C, there's no such thing as a "variable length" string, as opposed
    >> to fixed length string. The C standard does not specify a particular
    >> character set, like ASCII, and it doesn't define RAM.
    >>
    >>> Would this work in a disk field? What
    >>> are some considerations to be aware of?

    >>
    >> Yes strings can be written to a disk file, and read back in with
    >> fprintf and fscanf among other functions.

    >
    > At the risk of doing part of the OP's homework, text written to a file
    > is typically in the form of lines (terminated by '\n'), not strings
    > (terminated by '\0').


    Of course, writing '\0' into a file will work just fine (but I wouldn't
    suggest using a text file if you're going to do that).


    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
     
    Richard Heathfield, Mar 7, 2007
    #8
  9. uche

    Richard Bos Guest

    (Richard Tobin) wrote:

    > In article <>,
    > CBFalconer <> wrote:
    >
    > >wheat grows in wheat fields
    > >corn grows in corn fields
    > >hay grows in hay fields
    > >poppies grow in poppy fields
    > >disks grow in disk fields.

    >
    > Magnets produce magnetic fields, electricity produces electric fields, ...


    <sings> Gravity fields forever... </sings>

    Richard
     
    Richard Bos, Mar 7, 2007
    #9
  10. uche

    jaysome Guest

    On Wed, 07 Mar 2007 07:49:57 GMT, (Richard
    Bos) wrote:

    > (Richard Tobin) wrote:
    >
    >> In article <>,
    >> CBFalconer <> wrote:
    >>
    >> >wheat grows in wheat fields
    >> >corn grows in corn fields
    >> >hay grows in hay fields
    >> >poppies grow in poppy fields
    >> >disks grow in disk fields.

    >>
    >> Magnets produce magnetic fields, electricity produces electric fields, ...

    >
    ><sings> Gravity fields forever... </sings>


    Lennon would have enjoyed to have you around.

    --
    jay

    http://en.wikipedia.org/wiki/John_Lennon
     
    jaysome, Mar 7, 2007
    #10
  11. uche

    Joe Wright Guest

    uche wrote:
    > Hello all! I have thought about this question for a long time and I
    > would like to know your opinion about it: In C, a variable-length
    > string can be carried in RAM as a sequence of ASCII characters
    > followed by a NULL character. Would this work in a disk field? What
    > are some considerations to be aware of?
    >

    Just to keep things clear, NULL is a pointer constant, not a character.
    The character is often referred to as NUL or '\0' or simply 0.

    The string is an array of char ending with (and including) '\0'. The
    string is a memory thing. The analogous stream (file) thing is a line. A
    line is a series of bytes ending with (and including) '\n', a newline.

    I (and others) consider text files with '\0' characters to be corrupted.

    --
    Joe Wright
    "Everything should be made as simple as possible, but not simpler."
    --- Albert Einstein ---
     
    Joe Wright, Mar 7, 2007
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Posey
    Replies:
    0
    Views:
    681
    Robert Posey
    Nov 26, 2003
  2. Mitchua
    Replies:
    5
    Views:
    2,748
    Eric J. Roode
    Jul 17, 2003
  3. ashu
    Replies:
    1
    Views:
    464
  4. ashu
    Replies:
    2
    Views:
    619
    mysticlol
    Nov 6, 2006
  5. Xin Xiao

    Block RAM Distributed RAM

    Xin Xiao, Jan 7, 2008, in forum: VHDL
    Replies:
    8
    Views:
    1,478
    Duane Clark
    Jan 7, 2008
Loading...

Share This Page