467,154 Members | 989 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,154 developers. It's quick & easy.

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.
Aug 20 '08 #1
  • viewed: 2686
Share:
5 Replies
On Aug 20, 12:33*pm, Stuudent <wojtek.jurkowlan...@gmail.comwrote:
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="#FFFFFF">
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
Aug 20 '08 #2
On 20 Sie, 23:05, Fred <fred.l.kleinschm...@boeing.comwrote:
On Aug 20, 12:33*pm, Stuudent <wojtek.jurkowlan...@gmail.comwrote:
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="#FFFFFF">
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.
Aug 20 '08 #3
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
Aug 20 '08 #4
"Fred" <fr*****************@boeing.comwrote in message
news:bb**********************************@a3g2000p rm.googlegroups.com...
On Aug 20, 12:33 pm, Stuudent <wojtek.jurkowlan...@gmail.comwrote:
>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="#FFFFFF">
is it BODY, or TEXT, or TEXT="#000000", or something else?
Such as 0x444F?

(ascii OD as word)

Aug 21 '08 #5
On Aug 20, 4:05 pm, Fred <fr*****************@boeing.comwrote:
On Aug 20, 12:33 pm, Stuudent <wojtek.jurkowlan...@gmail.comwrote:
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

Aug 21 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Phil Slater | last post: by
2 posts views Thread by Eric Lilja | last post: by
16 posts views Thread by Jm.GlezdeRueda@gmail.com | last post: by
24 posts views Thread by arnuld | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.