Reading char* word by word

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stuudent

    Reading char* word by word

    Hi!
    Is there possibility to read char* table word by word in C (not C++)?
    I'm learning C by writing simple HTTP Server on BSD sockets (just for
    fun). And I want to read info from HTTP header received from client. I
    get char table, and I have to read some information.
    Can you help me?

    I can post the whole code of server when I finish.
  • Fred

    #2
    Re: Reading char* word by word

    On Aug 20, 12:33 pm, Stuudent <wojtek.jurkowl an...@gmail.com wrote:
    Hi!
    Is there possibility to read char* table word by word in C (not C++)?
    I'm learning C by writing simple HTTP Server on BSD sockets (just for
    fun). And I want to read info from HTTP header received from client. I
    get char table, and I have to read some information.
    Can you help me?
    >
    I can post the whole code of server when I finish.
    First you have to define what you want "word" to mean.
    For example, what is the second "word" in this line:
    <BODY TEXT="#000000" BGCOLOR="#FFFFF F">
    is it BODY, or TEXT, or TEXT="#000000", or something else?
    if you want it to be TEXT, what is the next "word"?
    Is it
    ="#000000"
    or
    #000000

    --
    Fred Kleinschmidt

    Comment

    • Stuudent

      #3
      Re: Reading char* word by word

      On 20 Sie, 23:05, Fred <fred.l.kleinsc hm...@boeing.co mwrote:
      On Aug 20, 12:33 pm, Stuudent <wojtek.jurkowl an...@gmail.com wrote:
      >
      Hi!
      Is there possibility to read char* table word by word in C (not C++)?
      I'm learning C by writing simple HTTP Server on BSD sockets (just for
      fun). And I want to read info from HTTP header received from client. I
      get char table, and I have to read some information.
      Can you help me?
      >
      I can post the whole code of server when I finish.
      >
      First you have to define what you want "word" to mean.
      For example, what is the second "word" in this line:
         <BODY TEXT="#000000" BGCOLOR="#FFFFF F">
      is it BODY, or TEXT, or TEXT="#000000", or something else?
      if you want it to be TEXT, what is the next "word"?
      Is it
        ="#000000"
      or
      #000000
      >
      --
      Fred Kleinschmidt
      Second word is ' TEXT="#000000 '
      word separated by space or \n.

      Comment

      • Pietro Cerutti

        #4
        Re: Reading char* word by word

        Stuudent wrote:
        Hi!
        Is there possibility to read char* table word by word in C (not C++)?
        I'm learning C by writing simple HTTP Server on BSD sockets (just for
        fun). And I want to read info from HTTP header received from client. I
        get char table, and I have to read some information.
        Can you help me?
        You may look at the strtok function.


        --
        Pietro Cerutti

        Comment

        • Harold Aptroot

          #5
          Re: Reading char* word by word

          "Fred" <fred.l.kleinsc hmidt@boeing.co mwrote in message
          news:bbc8227e-45eb-4511-9630-e609c440ede0@a3 g2000prm.google groups.com...
          On Aug 20, 12:33 pm, Stuudent <wojtek.jurkowl an...@gmail.com wrote:
          >Hi!
          >Is there possibility to read char* table word by word in C (not C++)?
          >I'm learning C by writing simple HTTP Server on BSD sockets (just for
          >fun). And I want to read info from HTTP header received from client. I
          >get char table, and I have to read some information.
          >Can you help me?
          >>
          >I can post the whole code of server when I finish.
          >
          First you have to define what you want "word" to mean.
          For example, what is the second "word" in this line:
          <BODY TEXT="#000000" BGCOLOR="#FFFFF F">
          is it BODY, or TEXT, or TEXT="#000000", or something else?
          Such as 0x444F?



          (ascii OD as word)

          Comment

          • s0suk3@gmail.com

            #6
            Re: Reading char* word by word

            On Aug 20, 4:05 pm, Fred <fred.l.kleinsc hmidt@boeing.co mwrote:
            On Aug 20, 12:33 pm, Stuudent <wojtek.jurkowl an...@gmail.com wrote:
            >
            Hi!
            Is there possibility to read char* table word by word in C (not C++)?
            I'm learning C by writing simple HTTP Server on BSD sockets (just for
            fun). And I want to read info from HTTP header received from client. I
            get char table, and I have to read some information.
            Can you help me?
            >
            I can post the whole code of server when I finish.
            >
            First you have to define what you want "word" to mean.
            Actually, HTTP already defines it. If you want to parse the request
            line, for example, it's easy, since the three items are separated by
            spaces. HTTP defines it as

            Request-Line = Method SP Request-URI SP HTTP-Version CRLF

            (Where SP means a space character, and CRLF means the sequence "\r\n"
            in C.) See RFC 2616 for further details.

            With this in mind, you can either parse it with strtok(), or simply go
            through the buffer examining character by character.

            <snip>

            Sebastian

            Comment

            Working...